using Express in a Node project along with Typescript what would be the "best practices" for express.Router.
example directory structure
|directory_name
---server.js
|--node_modules
|--routes
---index.ts
|--admin
---admin.ts
|--products
---products.ts
|--authentication
---authentication.ts
so inside index.ts it would encapsulate and manage all the sub-routers
//admin.ts (nested inside of index.ts)
import * as express from "express";
export = (() => {
let router = express.Router();
router.get('/admin', (req, res) => {
res.json({success: true});
});
return router;
})();
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…