Skip to content

Quickstart

jarnoux edited this page Jun 24, 2013 · 5 revisions
  1. Create your entry point file: server.js
var Rig = require('rig'),
    rig = new Rig({
        config: 'config.json',
        routes: 'routes.json'
    });

rig.register('middleware.myMiddleware', function (config) {
    return function (req, res, next) {
        res.end(config.message);
    };
});

rig.route();

rig.listen(3000);
console.log('app listening on port', 3000);
  1. Create your configuration file: config.json
{
    "middleware": {
        "myMiddleware": {
            "message": "Hello World!\n"
        }
    }
}
  1. Create your routes file: routes.json
{
    "": ["middleware.myMiddleware"]
}
  1. Install Rig and start your app
$ npm install rig
$ node ./server.js
  1. Done! Try localhost:3000 in your browser now :)
Something went wrong with that request. Please try again.