What are the template variables that express4 uses to set ejs?

  node.js, question

Recently, I was thinking about how to assign a value in advance to the variables of express’s template. Reduce the problem of multiple routes setting the same variable.

The following is the assignment method that I currently think of:

1. Global assignment

var app = express();
 app.locals['username'] = 'xxx';

2. Local assignment

app.use('/', function (req, res) {
 username: 'xxx'

Question: Is it possible to assign a value to an intermediate piece, such as:

app.use(function (req, res, next) {
 //assign value to res

I recently learned that,
Can be used
res.localsSave local variables