1.1.1 • Published 6 years ago
ducatea-express v1.1.1
Code with Passion
Personal purpose - Lazy for Create new project
Happy time ^_^
Email: taddev916@gmail.com (email if you want other features or improve. thanks <3
)
RECOMMENDED
Review Code to use :D
Installation
$ npm install ducatea-express
How to use
test-route.js
const
DucateaRouter = require("aa-ducatea/router");
let rts = {
"tt": [{
method: "get",
name: "test-app",
middleware: false,
action: function (req, res) {
res.json({
message: req.url,
})
}
}, {
method: "get",
name: "test-route",
controller: "AppController@test-route",
}],
1: [{
method: "get",
name: "test-app/hi/:id",
middleware: "test-app",
controller: "AppController"
}, {
method: "get",
name: "tt/test-app",
middleware: ["test-app", "hihi"],
controller: "AppController@test-app-2",
}]
};
class Router extends DucateaRouter {
constructor(props) {
super(props);
this.setRouterConfigs(rts);
}
}
let CONFIG_ROUTER = {
validatorDir: "routes/validator", // [project-folder]/ middleware
controllersDir: "controllers", // [project-folder]/ controller
};
module.exports = (new Router(CONFIG_ROUTER)).Router();
app.js
const app = require("express")();
app.use(require("./[path test-router.js]"))