Using app.set vs app.value in Express

In my app.js file, I use app.set(valName, value)to pass several configuration parameters to my routes.
Then I pass the application on their routes: app.use('/', require('./routes/index')(app));
Then I can easily use app.get(valName)to extract values ​​in routes.

My question is: would it not be easier to just use app.valName = value;and then just access the app.valNameroute?
Do I need to use .setand .get? Or will it break something?

+4
source share
1 answer

Do I need to use .setand .get? Or will it break something?

? . ? !

app (, app.valName = value;), , Express .

- , - init:

this._baseRoutes = {};
this.cache = {};
this.settings = {};
this.engines = {};
this.defaultConfiguration();

defaultConfiguration function. , cache, settings engines, , , Express toes , , , .

app.set , , . : .

+4

Source: https://habr.com/ru/post/1541157/


All Articles