-
Notifications
You must be signed in to change notification settings - Fork 2
Rig
jarnoux edited this page Dec 1, 2013
·
2 revisions
Rig is the constructor for your app. It is the entry-point to specifying how your app is structured and what resource should be configured with what and how to route it.
// server.js
var Rig = require('rig'),
rig = new Rig({
config: 'config.json',
routes: 'routes.json'
});
rig.register('controllers/');
rig.register('middleware/');
rig.register('models/');
rig.route();
rig.listen(3000);
console.log('app listening on port', 3000);
// server.js
var Rig = require('rig'),
rig = new Rig({
config: 'config.json',
routes: 'routes.json',
resources: ['controllers/', 'middleware/', 'models/']
});
rig.listen(3000);
console.log('app listening on port', 3000);
That's right: if you only need the 1-argument version of the rig.register function (which should be often), then you can specify those arguments in an array in the
resources
parameter and Rig will register and route everything automatically for you (See below for more about that).
The constructor for a new Rig app.
- String config: The path of the config file absolute or relative to the root of the app.
- String routes: The path of the routes file absolute or relative to the root of the app.
- String[] resources (optional): The resources path to be sequentially given to
rig.register
. If this argument is present, rig will register those resources and callRig.route
See the registry.
Applies the routing configurations to the app to define what resources is called when. You can read more about routing on the Express.js website.
See Express.listen which is in turn Node's listen
See Express.engine.