0
Well, I’m learning how to implement MVC with the Express framework, but I came across the following situation in my app.js file:
var express = require('express');
var consign = require('consign');
var bodyParser = require('body-parser');
var app = express();
var router = express.Router();
app.set('view engine', 'ejs');
app.set('views', './app/views');
app.use(express.static('./app/public'));
app.use(bodyParser.urlencoded({extended: true}));
consign()
.include('app/routes')
.then('config/dbConnection.js')
.then('app/models')
.then('app/controllers')
.into(app);
module.exports = app;
In my controller, I wanted to have access to this "configuration" without having to import the modules again, mainly using the methods of var router = express.Router();
Is it possible? And what’s the best way to do that?