A
A
Arktares2018-02-02 18:45:21
Node.js
Arktares, 2018-02-02 18:45:21

Middleware in the router?

There is a main application file - app.js.
It includes, for example, middleware:

app.enable('trust proxy');
app.use(helmet());
app.use(compression());

Next, the router is connected:
var baseRouter = require('./routes/baseRouter.js');
app.use('/', baseRouter);

Question. will the middleware from app.js already work for baseRouter.js? Or should it be duplicated inside baseRouter.js?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-02-02
@Arktares

Yes, it will.
Application
Layer Middleware Router Layer Middleware

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question