rest-sugar makes it easy to implement yummy REST APIs
The whole point of this library is to make it easy to implement simple yet powerful REST APIs. There are a few extension points you can hook into. mongoose-sugar complements this particular library very well. It is possible to implement similar solutions for other backends too as long as you stick to the sugar-spec.
Even though the library has been designed based on Express, it might be possible to make it work with other similar libraries too given they use Express conventions. This might take some kind of an adapter.
The following urls contain a prefix given at init.
Note that it is possible to mix and match various GETs above. The following urls operate on a specific resource (ie. /<api>/<id>).
In case you want to use some authentication method (preferable!) or
customize the behavior further, consider using middlewares. You may attach
post middleware handlers.
pre ones are performed before an
actual database query performed whereas
post ones are after. The basic syntax
resembles Express. See the example below:
...var api =;api;// api.post is identical except the functions get an extra parameter containing// the data fetched from the database. You may then use that data to trigger// further actions for instance
Examine the tests included with the project for more complete examples.
rest-sugar is available under MIT. See LICENSE for more details.