April 2020
Intermediate to advanced
292 pages
6h 50m
English
Here is the start of our middleware:
| 1: | const express = require('express') |
| - | const { join } = require('path') |
| - | |
| - | const attachLocals = require('./attach-locals') |
| 5: | const lastResortErrorHandler = require('./last-resort-error-handler') |
| - | const primeRequestContext = require('./prime-request-context') |
| - | function mountMiddleware (app, env) { |
| - | app.use(lastResortErrorHandler) |
| - | app.use(primeRequestContext) |
| 10: | app.use(attachLocals) |
| - | app.use( |
| - | express.static(join(__dirname, '..', 'public'), { maxAge: 86400000 })) |
| - | } |
| - | |
| 15: | module.exports = mountMiddleware |
Middlewares in Express are functions that we run as part of the request/response cycle and ...
Read now
Unlock full access