Q:

nodejs - express how it is possible to make the global variables on all routes?

how it is possible to make my LANG is global on all routes ?
ex:
app.post('/set/lang',function(req,res){
   req.lang = 'en';
   res.json({lang:'en'});
});

app.get('/get/lang',function(){
res.json({lang:req.lang});
});

but return // {lang:undefined} ??
how I can do this? > /get/lang => return {lang:en}

A:

req.lang is undefined becasue the request to /get/lang is stateless and does not know about the state of the request done on /set/lang.
What you need here is a session service such as https://github.com/expressjs/session
you may want to read more here http://expressjs-book.com/forums/topic/express-js-sessions-a-detailed-tutorial/
My understanding being that you want to save user language foreach user and let them set it via a sort of language selector in your client app.
Note also, the question is confusing as it may also refer to global named parameters in expressjs which you could implement with https://github.com/expressjs/express-params.
Or, it may also refer to an input content validation, see more at http://expressjs.com/4x/api.html#app.param
Finally the version is not provided i assume it is the latest 4.x branch.

