1
In the Laravel Framework we have the configuration files centralized in the directory /config
, these are simple files php returning a array key and value.
To access these settings anywhere in the application we can use the Helper config
, therefore, when using config('app.timezone');
we can access the contents of /config/app.php, key timezone
and return the value of this.
How could it have a similar behavior in nodejs, preferably using a Helper as simple as the one mentioned above?
Note: if relevant, I am using Express.js in the project.
Could you point me to an autoloader that allows me to dynamically "require"? I would like to import into root something that when called invokes the corresponding file, example:
config(‘app.port')
. In short, the function would considerapp
as archive andport
as key, for the previous example.– Fábio Jânio