0
I’m having the following difficulty:
I have the following design structure:
my server.js
is the start of the project.
However, within the services, models
, etc I have some libs
, as an example log
which according to Environment it shows on the console or goes to a log file.
So here are two items to question and ask for your help:
1 - I need to put the require
in the lib of log
in all files? I know there is global.
, but in the vscode, it does not show the scope. It only shows with const, var ou let
.
See the example below with global.
and with const
with global shows server scope
-
and with overall type is any
2 - this function I have in the log, which is the setenv(env) I also need to set in all files?
It’s almost never a good idea to use global variables for the application. It is worth much more you create a module and use it as such: import it where you need it.
– Luiz Felipe
then your suggestion is to have a module type env.js that will initialize all these conditions?
– VMCO
something else...I know it runs a little bit from the original question, but what is the best way to deal with relative paths?
– VMCO