This package has been deprecated

Author message:

use mio-express instead

mio-resource

0.8.0 • Public • Published

mio-resource

Build Status Coverage Status NPM version Dependency Status

Expose Mio models via RESTful resource middleware.

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

Installation

npm install mio-resource

Example

Use with express:

var express = require('express')
  , mio = require('mio');
 
var User = mio.createModel('User');
 
User
  .attr('id')
  .attr('name')
  .use('server', 'mio-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);

Events

request loaded model

Emitted whenever a model instance is loaded inside of a request.

User.on('request loaded model', function(req, user) {
  // ...
});

MIT Licensed

Package Sidebar

Install

npm i mio-resource

Weekly Downloads

0

Version

0.8.0

License

MIT

Last publish

Collaborators

  • amingoia