Article directory
1. First introduction to Express
【1】Express Introduction
【1-1】
什么是 Express
Express’s Chinese official website: http://www.expressjs.com.cn/
【1-2】
进一步理解 Express
【1-3】
Express 能做什么
【2】Basic use of Express
【3】Host static resources
【3-1】
express.static()
【3-2】
托管多个静态资源目录
【3-3】
挂载路径前缀
[Case]
默认显示没有前缀的静态资源目录
If there are multiple static resource directories without prefixes, load the first one
(if the previous directory is not available, then load the later directory)
[4] nodemon
【4-1】
为什么要使用 nodemon
( https://www.npmjs.com/package/nodemon )
But if vs code turns on automatic saving, nodemon will keep restarting the project, and an error will occur. Solution: ctrl+c=》 Start the project (or turn off autosave)
【4-2】
安装 nodemon与使用
2. Express routing
【1】The concept of routing
【2】Use of routing
【2-1】
最简单的用法
【2-2】
模块化路由
【Case】
(1) Create routing module
(2) Register routing module
3. Express middleware
【1】The concept of middleware
【1-1】
什么是中间件
【1-2】
Express 中间件的调用流程
【1-3】
Express 中间件的格式
【1-4】
next 函数的作用
【2】First experience with Express middleware
【2-1】
定义中间件函数
【2-2】
全局生效的中间件
【2-3】
中间件的作用
【2-4】
局部生效的中间件
【2-5】
了解中间件的5个使用注意事项
【3】Classification of middleware
【3-1】
应用级别的中间件
【3-2】
路由级别的中间件
【3-3】
错误级别的中间件
【3-4】
Express内置的中间件
【3-5】
路由级别的中间件
【4】Customized middleware
[4-1] Requirement description and implementation steps
[4-2] Encapsulate custom middleware into modules
4. Use Express writing interface
【1】Create a basic server
【2】Create API routing module
【3】Write GET interface
【4】Write POST interface
【5】CORS cross-domain resource sharing
【5-1】
使用 cors 中间件解决跨域问题
【5-2】
什么是 CORS
【5-3】
CORS 响应头部 - Access-Control-Allow-Origin
【5-4】
CORS 响应头部 - Access-Control-Allow-Headers
【5-5】
CORS 响应头部 - Access-Control-Allow-Methods
【5-6】
CORS请求的分类
【6】JSONP interface
【Case】