I have all the database calls directly inside /routes/*:
e.g.
//routes/users.ts
route.get("/id", (req, res) => {
res.send(db.findOne(id: req.sessions.id));
});
But someone said I should put the code inside /controllers/.
But I find that I just add an extraneous call with no benefit:
//routes/users.ts
route.get("/id", (req, res) => {
res.send(userController);
});
And inside /controllers/:
//controllers/userController.ts
export default function users() {
return db.findOne(id: req.sessions.id);
}
Is this approach somehow better?
Now the routes folder is just a thin shim to the controller. I see no benefit to the change.