摘要: 自定义中间件: // 导入express模块 const express = require('express') // 创建express的服务器实例 const app = express() // 1. 导入自己封装的中间件模块 const customBodyParser = require 阅读全文
posted @ 2020-08-24 21:27 彬戈戎马 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 中间件的数据流向如以下图所示: 阅读全文
posted @ 2020-08-23 14:06 彬戈戎马 阅读(190) 评论(0) 推荐(1) 编辑
摘要: 模块化重点记住一下这句话: 使用require模块时得到的永远是module.exports的对象 模块化代码如下: // module.exports 相当于一个共享方法 module.exports.username = 'zs'; module.exports.nihao = () => { 阅读全文
posted @ 2020-08-22 19:13 彬戈戎马 阅读(118) 评论(0) 推荐(1) 编辑
摘要: 创建index.js 文件里面的内容为: // index.js文件 // 包的入口文件 const date = require('./src/dataFormat') const escape = require('./src/htmlEscape') // 向外暴露需要的成员 module.e 阅读全文
posted @ 2020-08-22 19:02 彬戈戎马 阅读(136) 评论(0) 推荐(1) 编辑
摘要: const express = require('express') const app = express() // 定义一个中间件函数 // const mw = (req, res, next) => { // console.log('最简单的中间件函数') // 把流转的关系转交给下一个中 阅读全文
posted @ 2020-08-22 18:47 彬戈戎马 阅读(142) 评论(0) 推荐(1) 编辑
摘要: 我没有高颜值的外表,没有可以挥霍的资本,也没人喜欢我三五年; 我就是想漫无目的的走走努力发一笔小财然后买些自己喜欢的东西; 还有一些小时候未曾实现过的东西 阅读全文
posted @ 2020-08-19 20:40 彬戈戎马 阅读(109) 评论(0) 推荐(1) 编辑