modella-resource

Expose Modella models via RESTful resource middleware.

npm install modella-resource
65 downloads in the last month

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

npm loves you