Does express middleware have to be placed in the inside of app.js?

  node.js, question

Does express middleware have to be placed in the inside of app.js? If I want to put the middleware into a separate module, inside, and then require to come in?

For example, I don’t want to put the following codes in app.js inside. How should inside operate if it is placed in a module alone? I tried to re-create a file called appconfig.js, then put the middleware in the file inside, export it through module.export=app, and then use the original app.js inside Request (‘./AppConfig’), but the result was not good, that is, the middleware require(‘./appconfig. JS inside did not work. Under the guidance of the great god, thank you!

 var express = require('express');
 var app = express();
 var path = require('path');
 var favicon = require('serve-favicon');
 var cookieParser = require('cookie-parser');
 var bodyParser = require('body-parser');
 app.set('views', path.join(__dirname, 'views'));
 app.set('view engine', 'ejs');
 extended: false
 app.use(express.static(path.join(__dirname, 'public')));
 var app=require('./appconfig');

May I know how to write require before appconfig.js inside’s middleware takes effect?

Express () has already been called in appconfig.js inside. Why call it again in app.js? . .