A Seneca.js plugin to expose your data as REST API
- Version: 0.3.1
- Tested on: Seneca 0.7.1
- Node: 0.10, 0.11, 0.12, 4
Exposes your data entities as a REST API. For example, if you have a data entity called foo, then the following end points will become available:
- GET /api/rest/foo: return a list of all foo entities
- GET /api/rest/foo/:id: return a single foo entity by identifier
- POST /api/rest/foo: create a new foo entity
- PUT /api/rest/foo/:id: update a foo entity
You can use the plugin options to change the URL prefix, and to add additional behaviours.
Note that it is not necessary for the underlying entity to be persistent. You can define a virtual entity foo by providing actions for the patterns:
- role:entity,name:foo,cmd:save
- role:entity,name:foo,cmd:load
- role:entity,name:foo,cmd:list
- role:entity,name:foo,cmd:remove
If you are new to Seneca in general, please take a look at senecajs.org. We have everything from tutorials to sample apps to help get you up and running quickly.
If you're using this module, and need help, you can:
- Post a github issue,
- Tweet to @senecajs,
- Ask on the Gitter.
To install, simply use npm. Remember you will need to installSeneca.js if you haven't already.
npm install seneca
npm install seneca-jsonrest-api
require('seneca')()
.use('jsonrest-api')
You can seneca.use this plugin multiple times to create multiple independent API end points, so long as you specify different prefixes. The prefix option is used to create separate action patterns so that they do not conflict.
- prefix: a custom prefix
- pins: an array of entity pins, with properties name,base,zone. These define the data entities that will be exposed.
- tests in this repository
- seneca-examples/api-server
- seneca-data-editor
The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.
Copyright Richard Rodger and other contributors 2015, Licensed under MIT.