JSON API
A simple middleware for mounting a RESTful JSON API
Usage
Add as a middleware
var Datastore = ;var store = filename: "path/to/file" autoload: true ;var json_api = ; app;
create a record:
curl -4 -X POST -H "Content-Type: application/json" -d '{"name":"curl"}' http://localhost:8025/path/to/mount/to
get a record:
curl -4 -X GET -H "Content-Type: application/json" http://localhost:8025/path/to/mount/to/<resource-id>
I have only tested with NeDB but should also work with MongoDB
Check out the tests to see more usage examples.
Testing
npm install -g mochamocha
Similar Projects
Why?
If you read this article from StrongLoop about comparing different libraries for building RESTful APIs
I would add this with the following entry:
var app = ;var Store = var store = filename: "data/items.db" autoload: true ; app ; app;
Pros
- Very quick RESTful API development
- Just a simple middleware to inject into your existing workflow
- Great for prototyping
- No learning curve
- Very lightweight (can read entire source in a few minutes)
Cons
- Only built with NeDB/MongoDB in mind
- Only inteded for trivial apps, prototypes or stubs