express-ion-controller
v1.0.1
Published
Laravel like, express controller adapter
Downloads
1
Maintainers
Readme
express-ion-controller
fega-express-ion-controller
Laravel like, express controller adapter
Installation
$ npm install express-ion-controller --save
Usage
when the controller is a module
In your express router:
var express = require('express');
var router = express.Router();
var controller = require('express-ion-controller');
router.get('/',controller('controller'));
In a app/controllers/controller.js file (as you can see is a normal express middleware)
module.exports = (req, res, next) => {
res.render('index', { title: 'controller' });
}
when you have nested controllers
Your express router
router.get('/',controller('another-controller@inner');
In a app/controllers/another-controllers.js
module.exports = {
nested(req,res,next){
res.render('index', { title: 'controller nested' });
}
}
set your own controllers folder
In the express router
var express = require('express');
var router = express.Router();
var expController = require('express-ion-controller');
var controller = (c)=>{
return expController(c,'path from app/ directory')
}
router.get('/',controller('controller'));
License
MIT © Fabian Gutierrez