Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A HTTP JSON REST API for Seneca entities
JavaScript CSS Shell
branch: master
Failed to load latest commit information.
doc
test version 0.3.0; seneca 0.6.1; better tests
.gitignore fix url parsing
.npmignore
.travis.yml
LICENSE.txt
README.md version 0.3.1; allow external ids
build.sh
jsonrest-api.js
package.json version 0.3.1; allow external ids
test.sh version 0.3.1; allow external ids

README.md

seneca-jsonrest-api - a Seneca plugin

Seneca HTTP JSON REST API Plugin

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

Options

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.

Examples

Support

Current Version: 0.3.1

Tested on: Node 0.10.36, Seneca 0.6.1

Build Status

Annotated Source Code.

If you're using this module, feel free to contact me on Twitter if you have any questions! :) @rjrodger

Gitter chat

Install

To install and add to the dependencies list in the package.json file for your project:

npm install seneca-jsonrest-api --save

And in your code:

var seneca = require('seneca')()
    .use( 'jsonrest-api' )
Something went wrong with that request. Please try again.