using Express in a Node project along with Typescript what would be the \"best practices\" for express.Router.
example directory structure
|directory
In NodeJS each file is a module. Declaring variables does not pollute the global namespace. So you don't need to use the good old IIFE
trick to properly scope variables (and prevent global pollution / collision).
You would write:
import * as express from "express";
// import sub-routers
import * as adminRouter from "./admin/admin";
import * as productRouter from "./products/products";
let router = express.Router();
// mount express paths, any addition middleware can be added as well.
// ex. router.use('/pathway', middleware_function, sub-router);
router.use('/products', productRouter);
router.use('/admin', adminRouter);
// Export the router
export = router;
https://basarat.gitbooks.io/typescript/content/docs/project/modules.html