project_mern_memories
project_mern_memories copied to clipboard
why do you need to make an instance of express() also in the conrollers
https://github.com/adrianhajdin/project_mern_memories/blob/6011a17ce778e50e0f46b2ffe98ad3edb8191ed0/server/controllers/posts.js#L6
why do you need to make an instance of express() also in the conrollers. It already done in routes folder.
Cause express works like this.
So, of course, he can juste import Router
from express
, but in that tutorial, the goal is to learn a bit about back-end developpement and more about MERN projects, but for beginners it's better to know how it works.
But I'm agree with you, we haven't got to make a new instance express.
I don't know if you understand correctly all I say ^^"
As far as I understand the purpose of controllers folder is only to implement the logic of the routes folder. And if we create an instance of express as a router in the routes folder, it doesn't necessary neither to make another instance nor to import router in the controller folder. The imports is from the other direction: we import the logics functions from controllers folder to the routes folder