0.1.23 • Published 6 years ago
agua v0.1.23
Warning
This project is under development. Come back later.
Installation
agua requires node v7.6.0 or higher for ES2015 and async function support
$ npm install agua
Usage
Application structure
├── package.json
├── app.js (optional)
├── agent.js (optional)
├── app
| ├── router.js
│ ├── controller
│ │ └── home.js
| ├── extend (optional)
│ | ├── helper.js (optional)
│ | ├── filter.js (optional)
│ | ├── request.js (optional)
│ | ├── response.js (optional)
│ | ├── context.js (optional)
│ | ├── application.js (optional)
│ | └── agent.js (optional)
│ ├── service (optional)
│ ├── middleware (optional)
│ │ └── response_time.js
├── config
| ├── config.default.js
│ ├── config.prod.js
| ├── config.test.js (optional)
| ├── config.local.js (optional)
│ └── plugin.default.js
app.js
// app.js
const Agua = require('agua').Agua;
const app = new Agua({
basedir: path.resolve(__dirname),
});
app.listen(3000);
app/router.js
// app/router.js
module.exports = (app) => {
// app.get(name, path, 'controller.method');
app.get('homeIndex', '/home', 'home.index');
};
app/controller/home.js
// app/controller/home.js
module.exports = (app) => {
return class HomeController extends app.Controller {
async index() {
this.ctx.body = {
message: 'helloworld',
};
},
};
};
app/middleware/response_time.js
// app/middleware/response_time.js
module.exports = (options, app) => {
return async (ctx, next) => {
let startTime = new Date();
await next();
let endTime = new Date();
ctx.body = {
...ctx.body,
latency: (endTime - startTime).toString(),
};
};
};
config/config.default.js
// config/config.default.js
module.exports = {
middleware: ['response_time'],
'response_time': {
enable: true,
},
};
0.1.23
6 years ago
0.1.20
6 years ago
0.1.17
6 years ago
0.1.14
6 years ago
0.1.11
6 years ago
0.1.8
6 years ago
0.1.5
6 years ago
0.1.2
6 years ago
0.0.99
6 years ago
0.0.72
6 years ago
0.0.69
6 years ago
0.0.66
6 years ago
0.0.63
6 years ago
0.0.60
6 years ago
0.0.57
6 years ago
0.0.54
6 years ago
0.0.51
6 years ago
0.0.48
6 years ago
0.0.45
6 years ago
0.0.42
6 years ago
0.0.39
6 years ago
0.0.36
6 years ago
1.0.9
6 years ago
1.0.82
6 years ago
1.0.81
6 years ago
1.0.8
6 years ago
1.0.7
6 years ago
1.0.6
6 years ago
1.0.5
6 years ago
1.0.4
6 years ago
1.0.3
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago