core.io Express server module
npm install core.io-express-serverExpress server module.
- port:
- process.env.PORT
- process.env.NODE_APP_PORT
- 3000
- basepath: Used to create the path to views and public.
- locals: It will be made available to all requests through app.locals.
- routeLocas: Specify locals per route. Example:
``js`
routeLocals: {
'/admin': {
layout: require('path').resolve('./modules/dashboard/views/layout.ejs')
}
}
NOTE: Good idea to name all functions passed to app.use or router.use. Makes it easier to debug, which is true in general, since otherwise you would see as the output.
[mincer]:https://github.com/nodeca/mincer
`js`
res.send({
success: false,
message: error.message
});
#### Custom Error views
If our sub-app has the following view structure:
``
.
├── views
│ ├── error-layout.ejs
│ ├── 401.ejs
│ └── 403.ejs
The error view will be rendered with the following locals:
`js``
let locals = {
isErrorView: true,
status: status,
message: err.message,
error: err
};