Skip to content

Instantly share code, notes, and snippets.

@nisargap
Created January 3, 2017 22:53
Show Gist options
  • Save nisargap/690b586d9d01cf33984364f4eef8c106 to your computer and use it in GitHub Desktop.
Save nisargap/690b586d9d01cf33984364f4eef8c106 to your computer and use it in GitHub Desktop.
IndexRoute.js
// import in express
var express = require('express');
// get the express router
var router = express.Router();
// can also get this from another file
// var IndexRouteController = require('PATH TO INDEX ROUTE CONTROLLER"
var IndexRouteController = function(req, res) {
res.render('index', {
title: 'MEAN MVC'
});
}
// define routes for the express router
router.get('/', IndexRouteController);
// export the router
module.exports = router;
// Now in app.js
// You can var IndexRoute = require('PATH TO THIS FILE');
// app.use(IndexRoute);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment