0.0.12 • Published 12 years ago
exedra v0.0.12
Exedra
Routes and functions loader
For example: we have two dirs in a root of our project
/functions
/routes
In /functions
we have:
/functions/say.js
/functions/say.js
code:
// ATTENTION! Don't place your code outside export function, You'll not be able to connect with them, code from exports evaled in nodes VM, exedra passing other context into it
module.exports = function(){
var fn = {};
fn.hello = function(){
return 'hello';
}
}
In /routes
we have:
/routes/index.js /routes/index/foo.js
/routes/index.js
code:
module.export = function(){
// We will use this, because it`s express-namespace
this.get('/bar', function(req, res, next){}); // == 127.0.0.1:3000/bar
}
Now lets run our hello function from say.js
/routes/index/foo.js code:
module.exports = function(){
// Yeah, you could use app instead of this
app.get('/', function(req, res, next){ // == 127.0.0.1:3000/foo
res.send(fn.say.hello()); // calling funtcion hello from say.js
});
}
Ok. Now we need entry point
index.js
:
var express = require('express')
, Exedra = require('exedra')
, vs = { foo: 1, bar: 2 }; // This vars will be sended in context of each route/function
var app = vs.app = express.createServer(); // !!!WE NEED TO PASS app INTO vs
var exedra = new Exedra(vs);
exedra.functions({ foo: 1 }).routes({ foo: 2 }); // We can extend context
app.listen();
For more details see /examples/simple-project
0.0.12
12 years ago
0.0.11
12 years ago
0.0.10
12 years ago
0.0.9-5
12 years ago
0.0.9-4
12 years ago
0.0.9-2
12 years ago
0.0.9-1
12 years ago
0.0.7
12 years ago
0.0.6
12 years ago
0.0.5-1
12 years ago
0.0.5
12 years ago
0.0.4-2
12 years ago
0.0.4-1
13 years ago
0.0.4
13 years ago
0.0.3
13 years ago
0.0.2
13 years ago
0.0.1
13 years ago