Hi @arcdev1, first of all thank you so much for this repo and the lesson about clean architecture on Youtube. I learnt a lot from it and now I'm using both as a guideline for my first own node app.
In data-access/index.js there's something I had to do slightly different because it wasn't working the way you did it, which is here:
In my case, the variable declared in .env (URI in my case) is undefined because (as I found out) the whole data-access module gets executed even before src/index.js does, which contains dotenv.config(),. I solved this by moving URI and the instantiation of MongoClient inside the makeDb function, which gets executed only once the server is started.
I wonder what happened in my case would be expected and if there is any drawback with my solution?
I changed "start" script to this:
"start": "npm run clean && npm run build && cd dist && node index.js && npm run db"
and it fixed this problem for me. Not sure what other implications this has.
Hi @arcdev1, first of all thank you so much for this repo and the lesson about clean architecture on Youtube. I learnt a lot from it and now I'm using both as a guideline for my first own node app.
In
data-access/index.js
there's something I had to do slightly different because it wasn't working the way you did it, which is here:In my case, the variable declared in
.env
(URI in my case) is undefined because (as I found out) the whole data-access module gets executed even beforesrc/index.js
does, which contains dotenv.config(),. I solved this by moving URI and the instantiation of MongoClient inside themakeDb
function, which gets executed only once the server is started.I wonder what happened in my case would be expected and if there is any drawback with my solution?
Cheers.