You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i decided to learn node/express JS. And i want to begin with a good start, a good structure directly. And yours seems really fine.
I'm trying to adapt mine to yours, but i've few questions.
When I put this line "app.use(require('./controllers'))", the console said me "controller module doesn't exist" !
How does it work this middleware ?
if i understand, when you write this line, you "include" all controller file, right ?
Until now, i learned that all modules have to localize to node_modules folder. So, i suppose that the middleware tried to find controller.js in this folder.
Can you enlighten me ?
Thanks to share your knowledge,
Appreciate.
JL, from Belgium.
The text was updated successfully, but these errors were encountered:
Hi, im new in Javascript world too and im learning Express. that line gets confused to me too. but reading about 'require()' i realize when you require a folder, it search a file with the same name of the folder plus .js extension. if not find that, try to require a index.js (or other files). So, in the 'controllers' folder there is a index.js which 'use' the users.js and comments.js and exports in router.
Hi,
i decided to learn node/express JS. And i want to begin with a good start, a good structure directly. And yours seems really fine.
I'm trying to adapt mine to yours, but i've few questions.
When I put this line "app.use(require('./controllers'))", the console said me "controller module doesn't exist" !
How does it work this middleware ?
if i understand, when you write this line, you "include" all controller file, right ?
Until now, i learned that all modules have to localize to node_modules folder. So, i suppose that the middleware tried to find controller.js in this folder.
Can you enlighten me ?
Thanks to share your knowledge,
Appreciate.
JL, from Belgium.
The text was updated successfully, but these errors were encountered: