bookshelf-jsonapi

JSON API implementation using bookshelf models.

MIT License

Stars
12
Committers
2

bookshelf-jsonapi

Simple library that uses Bookshelf models and relationships to create a RESTful api based on jsonapi.org spec using an express 4 compatible middleware.

Usage

Define your Bookshelf models and their relationships. Pass an object to the jsonapi middleware that contains 'resourceName' => 'modelReference'. This should allow your application to serve jsonapi compatible rest services with very little setup.

var jsonapi = require('jsonapi-bookshelf');
var models = require('./models'); // key model name, value model object

app.use('/api', jsonapi(models));

Please refer to the tests to see detailed examples of how the middlware works