0.10.0 • Published 8 years ago

serene-express v0.10.0

Weekly downloads
9
License
ISC
Repository
github
Last release
8 years ago

serene-express

Allows you to use Serene with Express.

Installation

$ npm install --save serene-express

Usage

import express from 'express';
import Serene from 'serene';
import sereneExpress from 'serene-express';

let service = new Serene();
// set up service...

let app = express();
app.use(sereneExpress(service));

Documentation

This package maps the following routes to the specified Serene operations:

RouteSerene operation
GET /:resourcelist
GET /:resource/:idget
POST /:resourcecreate
PATCH /:resource/:idupdate
PUT /:resource/:idreplace
DELETE /:resource/:iddelete

It also defines an error handler that serialises the error to JSON in the error field of the response, using the status code specified by the status field on the error if it exists, or 500 by default.

If you pass false as a second argument to sereneExpress, it will not register the error handler nor the handler that formats the response to JSON. These handlers can be referenced manually like so:

import {errorHandler, formatJson} from 'serene-express';

This could be useful for setting it up to serialise to a different format, such as XML or CSV.

0.10.0

8 years ago

0.9.0

8 years ago

0.8.0

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.0

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago