FACG6 / CMSPosts

Link :
https://yourwordsapp.herokuapp.com/
0 stars 0 forks source link

Requiring the index file #16

Open NouraldinS opened 5 years ago

NouraldinS commented 5 years ago

https://github.com/FACG6/CMSPosts/blob/6df00bcc761329d8e4c90eca4f5a99ebb70d379d/src/app.js#L8

Node - by default - when requiring anything, it looks for `${theThing}.js`, if it didn't find that, it looks for `${theThing}/index.js` Examples:

require('./controllers/index.js'); // this would require exactly what you want
require('./controllers/index'); // this would look for the index.js otherwise it'd throw an error
require('./controllers'); // this would do the same as before
require('..'); // find the index.js in the parent folder

also also, https://github.com/FACG6/CMSPosts/blob/6df00bcc761329d8e4c90eca4f5a99ebb70d379d/src/database/queries/selectPostsViaUser.js#L1 You don't need to say ./.., .. is just enough.