README
express-rest-orm
express-rest-orm generates an express Router that serves a list of sequelize Models via a full-featured REST api.
getting started
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));
running the tests
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.
feature list
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 resourcesOPTIONS /
: list methodsGET /
: list resource urlsPOST /
: create resourcePUT /
: bulk update resourcesDELETE /
: delete all resources
/:id
: a single resourceGET /:id
: read resourcePOST /:id
: error -> usePUT /:id
orPOST /
PUT /:id
: update resourceDELETE /:id
: delete resource
/:id/:field
: all nested resourcesGET /: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