Search code examples
node.jsrestfixtures

Looking for a REST API with template based fake data (NodeJS + key-value store)


I want to be able to write a config like this...

{
    'collection' : 'payments',
    'rows'     : 100,
    'template' : {
        "id"            : "1...100000",
        "status"        : ["None", "SentToPayer", "Overdue", "Completed"],
        "amount"        : ["100","200","500"]
    }
}

...and it would create a key-value pair collection in a key-value store (maybe MongoDB) with 100 rows like this:

{
    "id": "80494",
    "status": "None",
    "amount": "200"
}

And the data would be fully accessible and editable trough a REST API.

GET http://server/payments/80494 would likely get me the node above.

I am pretty sure I've seen something like this before, but I'm not able to find it right now. Does anyone know something that gives me what I want?


Solution

  • I ended up creating my own thingy.

    This one puts data in an MongoDB database. https://github.com/janjarfalk/datafixture.js

    This one expose it. https://github.com/tdegrunt/mongodb-rest