Faster, cheaper, better web framework for Node.js, built on top of express.
$ npm install dp-node
- Rapid prototyping
- async / await ready
App
├─ controller
│ ├─ foo
│ │ ├─ bar
│ │ │ └─ index.js
│ │ └─ index.js
│ ├─ bar
│ └─ index.js
├─ model
│ ├─ foo
│ │ ├─ bar
│ │ │ └─ index.js
│ │ └─ index.js
│ ├─ bar
│ └─ index.js
├─ view
│ ├─ foo
│ │ ├─ foo.html
│ │ └─ bar.html
│ ├─ bar
│ │ └─ baz.html
│ └─ index.html
└─ index.js
App/controller/foo/bar/index.js / http://localhost/foo/bar
module.exports = {
async get() {
/*
* `this` exports: {
* raw: {
* req: return express `req` object.
* res: return express `res` object.
* }
* model: return model accessor
* session: return model accessor
* params: (key, isURL)
* headers: (key)
* redirect: (url, statusCode)
* render: (view, params)
* finish: (body)
* finisher: {
* notfound: (body)
* invalid: (body)
* error: (body)
* }
* finishWithCode: (code, body)
* }
*/
var arg1 = 10;
var arg2 = 20;
var res = this.model.foo.bar.add(arg1, arg2); // == 30
var params = {
arg1: arg1,
arg2: arg2,
res: res
};
await this.render('foo/foo.html', params);
}
};
module.exports = {
add(arg1, arg2) {
/*
* `this` exports: {
* knex: (dsn)
* row: (query, params, dsn)
* rows: (query, params, dsn)
* execute: (query, params, dsn)
* tran: (blocks, dsn)
* }
*/
return arg1 + arg2;
}
};
module.exports = {
add(arg1, arg2) {
/*
* `this` exports: helpers
*/
return arg1 + arg2;
}
};
<p>{{arg1}} + {{arg2}} = <strong>{{res}}</strong></p>
$ npm install dp-node