Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Minimal NodeJS REST server
JavaScript
Tree: 50cd1d46b4

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.idea
examples
lib
spec
README.md
package.json

README.md

rapid-rest

Minimal overhead NodeJS REST server.

Insprired by the amazing throughput of NodeJS but dissappointed by the overhead of the available libraries I decided to hone my own.

See rest-stress

or codeproject review

Installation and Usage

Install rapid-rest with npm

npm install rapid-rest 

The following call should be placed on your web facing server page.

    require('rapid-rest')

Syntax

The syntax is wholesale copy of the node-rest project which seems to have lost some of it's steam plus some smatterings of other REST syntaxes that I've used along the way.

Example 1:

Accept a GET request that has a single parameter in the path

routes('/there/:over_name')
    ('get', function(req, res, params){
        function(){
           alert("You requested:" + params.over_name)
        }
    });
routes.listen(port);

Example 2:

Accept a POST request with multiple parameter in the path

routes('/here/:here_name/:user')
    ('post', function(req, res, params, data){
       function(){
          alert("You sent:" + JSON.stringify(data) + " to " +  params.here_name  + " for user: " + params.user)
       }
    });

Example 3:

Accept a DELETE request with parameters defined in the path and with multiple required querystring parameters.

routes('/there/:where?here_name={here_name}&user={user}')
     ('delete', function(req, res, params){
         function(){
            alert("You're deleting:" + params.where + " where here_name is " +  req.query.here_name  
                           + ", for user: " + req.query.user)
         }
      });

Future development

  • Allow integration with middleware such as connect or express
  • More tests
Something went wrong with that request. Please try again.