Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
JavaScriptational State Stasfer
branch: master

This branch is 1 commit ahead of TheNodeILs:master

Failed to load latest commit information.
examples examples/package.json
tests Update JEST to using underscore.
.gitignore no node modules add app.router....
api.js Fixed underscore 1.5.2 issue which do not allow
authorization.js updating dependencies and changed class module to sji (Simple JavaScr…
cache.js no console.log on cache
index.js validation to Validation
mongoose_authorization.js ommit the use of set in Model fields settings
mongoose_resource.js allow unlimited results.
mongoose_validation.js updating dependencies and changed class module to sji (Simple JavaScr…
resource.js fix endswith operand
throttling.js updating dependencies and changed class module to sji (Simple JavaScr…
validation.js remove express-resource dependency


JavaScriptational State Transfer for node.js with easy generating resource from Mongoose ORM


This module provides Resource base class with:

  • Authentication
  • Authorization
  • Pagination
  • Cache
  • Throttling
  • Validation
  • MongooseResource
  • Resources listing


var express = require('express'),
    app = express(),
    Jest = require('jest'),
    mongoose = require('mongoose'),
    Schema = mongoose.Schema;


app.configure(function () {
    app.set('port', process.env.PORT || 80);

// create mongoose model

var User = mongoose.model('user', new Schema({
    username: {type: String, required: true},
    email: String,
    password: {type: String, validate: [function(v) { return true}, 'custom validate']},
    credits: {type: Number, min: 1, max: 230},
    role: {type: String, 'default': 'user' ,enum: ['user', 'admin']},
    date: {type:Date, 'default':},
    groups: [{name:String, permissions: [{name:String, expires:Date}]}]

// create mongoose resource for User model

var UserResource = Jest.MongooseResource.extend({
    init: function(){
        // call Jest.Resource constructor
        // passing the Model User we created

        // use array to decide which fields will be visible by API
        // this.fields = ['username','credits'];
        // use tree object to decide recursively which fields to expose
        this.fields = {username: true, credits: true, groups: {name: true, permissions: {name: true} }};

        // use list or
        this.update_fields = ['email', 'password'];

        // specify base query for the model
        this.default_query = function(query){
            return query.where('credits').gte(10);

        // specify which fields can be used to filter
        this.filtering = {credits: true};

        // which http methods are allowed
        this.allowed_methods = ['get', 'post', 'put'];

var api = new Jest.Api('api', app);

api.register('users', new UserResource());

app.listen(app.get('port'), function(){
    console.log('express started on port %d', app.get('port'));

now go to http://localhost/api/ to see the api's and http://localhost/api/users to work with User model the Jest way.


$ npm install jest


There is none. But there is an example, and a test.

And maybe one day will be...

Something went wrong with that request. Please try again.