Expose Modella models via RESTful resource middleware.
JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
README.md
package.json

README.md

modella-resource

Build Status Dependency Status

Expose Modella models via RESTful resource middleware.

This module can be paired with modella-ajax for automatic client-server communication.

Installation

npm install modella-resource

Example

Use with express:

var express = require('express')
  , modella = require('modella')
  , resource = require('modella-resource');

var User = modella('User');

User
  .attr('id')
  .attr('name')
  .use('server', resource());

var app = express();

app
  .use(express.bodyParser())
  .get('/users', User.middleware.index)
  .post('/users', User.middleware.create)
  .get('/users/:id', User.middleware.show)
  .put('/users/:id', User.middleware.update)
  .del('/users/:id', User.middleware.destroy);

Use with express-resource:

app.resource('users', User.middleware);

MIT Licensed