Expose Modella models via RESTful resource middleware.
This module can be paired with modella-ajax for automatic client-server communication.
npm install modella-resource
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);