HEADS UP: This project is no longer actively developed. Feel free to use it in the state it is, but I don't find the time and motivation to invest into this project.
express-rest-orm generates an express Router that serves a list of sequelize Models via a full-featured REST api.
Get the latest version of express-rest-orm via npm:
npm install [--save] express-rest-orm
Then use it to serve your sequelize Models:
var app = require('express')()
, Sequelize = require('sequelize')
, orm = new Sequelize('example', ...)
, models = [orm.define('foo', ...), orm.define('bar', ...)];
app.use('/api/v1', require('express-rest-orm')(models));
Tests are the main source of documentation for this module. They are kept readable so that they will not only pass but also convey information to the reader.
npm test
will run all tests and give a spec as well as coverage information.
See the latest travis build if you don't want to run the tests locally.
This is both a documentation of the features of express-rest-orm and a backlog of planned improvements. It is more or less copied from express-persistent-resource.
-
/
: all resources-
OPTIONS /
: list methods -
GET /
: list resource urls -
POST /
: create resource -
PUT /
: bulk update resources -
DELETE /
: delete all resources
-
-
/:id
: a single resource-
GET /:id
: read resource -
POST /:id
: error -> usePUT /:id
orPOST /
-
PUT /:id
: update resource -
DELETE /:id
: delete resource
-
-
/:id/:field
: all nested resources-
GET /:id/:field
: list nested resources (simulate withGET /:id?fields=:field
)
-
-
?
: query parameters-
?include_docs=true
: whenGET /?include_docs
, list docs instead of urls -
?:field=
: listresource
s that matchfilter
onfield
. Support-
=
: exact match -
~=
: one of -
|=
: exact match or starts with +-
(namespacing) -
^=
: starts with -
$=
: ends with -
*=
: contains
-
-
?fields=
: partial response (filtered byuntyped.validate
) -
?limit=
and?offset=
: pagination (limit
entries per call,offset
entries skipped) -
?q=
: search resources for query -
?method=
: override http method withmethod
(GET /?method=POST
equalsPOST /
) -
?suppress_response_codes=true
: override response code with200
, put response code in result
-
-
.:ext
: resource serialization-
.json
: (default) resources as json -
.xml
: resources as xml -
.yml
: resources as yaml
-
-
Accept:
: resource serialization-
*/json
: resources as json -
*/xml
: resources as xml -
*/yml
: resources as yaml
-