先最简单的代码
安装 npm install express
app.js 代码内容
const express = require('express') const app = express() //单项流动 const mid1 = () => (req, res, next) => { res.body = '请求1<br/>' next() } const mid2 = () => (req, res, next) => { res.body += '请求2<br/>' next() } const mid3 = () => (req, res, next) => { res.body += '请求3<br/>' next() } app.use(mid1()) app.use(mid2()) app.use(mid3()) app.get('/', (req,res,next) => { res.send(res.body +'业务处理中') }) app.listen(2334)