GithubHelp home page GithubHelp logo

ezmilhouse / superest.js Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 100 KB

superREST.js - a convenient wrapper for TJ's express-resource module

Home Page: http://ezmilhouse.github.com/supeREST.js/

JavaScript 100.00%

superest.js's Introduction

Superest.js

a convenient wrapper for TJ's express-resource for Node.js

Motivation

I wanted to have an easier way kickstart with mongoDB connected to express-resources. So now it works with mongoose for Node.js. It also supports auto-loading and nested resources.

Quickstart

Keep in mind that express-resources routes REST like this:

    /**
     *
     * GET     /resource           ->  index
     * POST    /resource           ->  create
     * GET     /resource/:id       ->  show
     * PUT     /resource/:id       ->  update
     * DELETE  /resource/:id       ->  destroy
     *
     **/
    // simple

    /**
     *
     * GET     /api/users           ->  index
     * POST    /api/users           ->  create
     * GET     /api/users/1234      ->  show
     * PUT     /api/users/1234      ->  update
     * DELETE  /api/users/1234      ->  destroy
     *
     **/

    superest.Resource
	    .create('users')
	    .db({
		    name   : 'myDB',
		    path   : 'mongodb://localhost',
		    schema : 'user'
	    })
	    .at({
		    base : 'api',
		    path : '/users'
	    })
	    .end();
    // nested

    /**
     *
     * GET     /api/users/1234/friends           ->  index
     * POST    /api/users/1234/friends           ->  create
     * GET     /api/users/1234/friends/5678      ->  show
     * PUT     /api/users/1234/friends/5678      ->  update
     * DELETE  /api/users/1234/friends/5678      ->  destroy
     *
     **/

    // resource: users
    superest.Resource
	    .create('users')
	    .db({
		    name   : 'myDB',
		    path   : 'mongodb://localhost',
		    schema : 'user'
	    })
	    .at({
		    base : 'api',
		    path : '/users'
	    })
	    .end();


    // resource: friends
    superest.Resource
        .create('friends')
        .db({
            name   : 'myDB',
            path   : 'mongodb://localhost',
            schema : 'friend'
        })
        .at('path', 'friends')
        .in('user') // to be nested in user schema
        .end();


    // create connection
    superest.Connection
    	.create('userFriends')
    	.set('/users/friends') // REST pseudo path (without IDs)
    	.end();

superest.js's People

Contributors

ezmilhouse avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.