├── index.js ├── 2-6. 联表查询 ├── index.js ├── .gitignore ├── distinct.sql ├── readme.md └── join.sql ├── 1-10. https协议 ├── index.js ├── public │ ├── script │ │ └── a.js │ ├── css │ │ └── index.css │ └── img │ │ └── u=2770282747,1971577128&fm=26&gp=0.jpg ├── .gitignore ├── 演示.pptx └── readme.md ├── 1-7. 文件流 ├── abc.txt ├── .gitignore └── readme.md ├── 2-4. 表记录的增删改 ├── index.js ├── .gitignore ├── delete.sql ├── update.sql └── readme.md ├── 2-5. 单表基本查询 ├── index.js ├── .gitignore ├── limit.sql ├── order by.sql └── readme.md ├── 2-7. 函数和分组 ├── index.js ├── .gitignore ├── readme.md ├── 数学函数.sql ├── 聚合函数.sql ├── 字符串和日期函数.sql └── 分组.sql ├── 1-6. 文件IO ├── myfiles │ ├── 1 │ │ ├── 3.txt │ │ └── 6.txt │ ├── 2.txt │ ├── sub │ │ └── 3.txt │ ├── 1.txt │ ├── 1.jpeg │ └── 1.copy.jpeg ├── .gitignore ├── readme.md ├── fs.mkdir.js ├── fs.readdir.js └── fs.stat.js ├── 3-2. Sequelize简介 ├── index.js ├── .gitignore ├── ORM原理图.jpg └── readme.md ├── 4-13. jwt ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── public │ └── css │ │ └── index.css ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-8. 断点调试 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── public │ ├── js │ │ └── index.js │ └── css │ │ └── index.css ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 三层架构.jpg ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 1-2. 全局对象 ├── .gitignore ├── readme.md ├── src │ └── index.js └── index.js ├── 4-10. 跨域之CORS ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── public │ ├── css │ │ └── index.css │ └── index.html ├── 三层架构.jpg ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-11. CORS中间件 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── public │ ├── css │ │ └── index.css │ └── index.html ├── 三层架构.jpg ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-12. session ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── public │ └── css │ │ └── index.css ├── 三层架构.jpg ├── init.js ├── session原理示意图.jpg ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-25. 场景 - 客户端缓存 ├── public │ ├── 1.asaf.js │ ├── 1.asfdasdf.css │ ├── img │ │ ├── logo.jpg │ │ └── water.jpg │ └── index.html ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ ├── apiLoggerMid.js │ └── proxyMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-5. express路由 ├── routes │ ├── api │ │ ├── book.js │ │ ├── admin.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── public │ ├── js │ │ └── index.js │ ├── css │ │ └── index.css │ └── index.html ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 三层架构.jpg ├── init.js ├── client │ └── readme.md ├── readme.md ├── nodemon.json ├── mock │ └── mockClass.js └── util │ └── propertyHelper.js ├── 4-7. 实现登陆和认证 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── public │ ├── js │ │ └── index.js │ └── css │ │ └── index.css ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 三层架构.jpg ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js └── util │ └── propertyHelper.js ├── 4-9. 跨域之JSONP ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── public │ ├── css │ │ └── index.css │ └── index.html ├── 三层架构.jpg ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 5-4. CSRF攻击和防御 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── public │ └── css │ │ └── index.css ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── danger │ └── index.html ├── 1-5. 基本内置模块 ├── .gitignore ├── readme.md └── about os.js ├── 4-14. 登录和认证-服务器开发 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── public │ └── css │ │ └── index.css ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-15. 登录和认证-客户端开发 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── client │ ├── .browserslistrc │ ├── babel.config.js │ ├── public │ │ └── favicon.ico │ ├── src │ │ ├── assets │ │ │ └── logo.png │ │ ├── views │ │ │ ├── Protect.vue │ │ │ └── Home.vue │ │ ├── store │ │ │ └── index.js │ │ └── main.js │ ├── vue.config.js │ └── readme.md ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── init.js ├── public │ ├── favicon.ico │ ├── img │ │ └── logo.82b9c7a5.png │ └── css │ │ └── app.5c9713c3.css ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-16. 场景 - 日志记录 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ ├── errorMiddleware.js │ └── apiLoggerMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── init.js ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-17. 场景 - 文件上传 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── apiLoggerMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── .gitignore ├── init.js ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-18. 场景 - 文件下载 ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ └── apiLoggerMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-19. 场景 - 图片水印 ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ └── apiLoggerMid.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── new.jpg ├── origin.jpg ├── water.jpg ├── init.js ├── public │ └── img │ │ └── water.jpg ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-20. 场景 - 图片防盗链 ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ └── apiLoggerMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── public │ ├── img │ │ ├── logo.jpg │ │ └── water.jpg │ └── index.html ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-21. 重要场景 - 代理 ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ ├── apiLoggerMid.js │ └── proxyMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 代理服务器.jpg ├── init.js ├── public │ ├── img │ │ ├── logo.jpg │ │ └── water.jpg │ └── index.html ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-22. 扩展场景 - 模版引擎 ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ ├── apiLoggerMid.js │ └── proxyMid.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── 两种渲染方式.jpg ├── public │ ├── img │ │ ├── logo.jpg │ │ └── water.jpg │ └── index.html ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js ├── test.ejs └── .vscode │ └── launch.json ├── 4-23. 场景 - 生成二维码 ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ ├── apiLoggerMid.js │ └── proxyMid.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── code.png ├── init.js ├── public │ └── img │ │ ├── logo.jpg │ │ └── water.jpg ├── .gitignore ├── nodemon.json ├── index.js ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-24. 场景 - 生成验证码 ├── routes │ ├── api │ │ ├── book.js │ │ ├── class.js │ │ └── download.js │ ├── apiLoggerMid.js │ └── proxyMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── public │ └── img │ │ ├── logo.jpg │ │ └── water.jpg ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-26. 场景 - 富文本框 ├── routes │ ├── api │ │ ├── class.js │ │ └── download.js │ ├── apiLoggerMid.js │ └── proxyMid.js ├── index.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── public │ └── img │ │ ├── logo.jpg │ │ └── water.jpg ├── .gitignore ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── .vscode │ └── launch.json ├── 4-6. cookie的基本概念 ├── routes │ ├── api │ │ ├── book.js │ │ └── class.js │ └── errorMiddleware.js ├── index.js ├── public │ ├── js │ │ └── index.js │ └── css │ │ └── index.css ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 三层架构.jpg ├── init.js ├── client │ └── readme.md ├── nodemon.json ├── mock │ └── mockClass.js └── util │ └── propertyHelper.js ├── 1-3. Node的模块化细节 ├── .gitignore ├── ab.js ├── a.json ├── src │ └── index.js ├── readme.md ├── myModule.js └── index copy.js ├── 1-4. 【扩展】Node中的ES模块 ├── .gitignore ├── index.mjs ├── a.mjs └── readme.md ├── 4-4. 常用中间件 ├── index.js ├── public │ ├── js │ │ └── index.js │ ├── css │ │ └── index.css │ └── index.html ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 三层架构.jpg ├── 中间件示意图.jpg ├── init.js ├── client │ └── readme.md ├── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── routes │ └── errorMiddleware.js ├── 1-8. net模块 ├── .gitignore ├── hsq.jpg └── readme.md ├── 4-3. express中间件 ├── index.js ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 三层架构.jpg ├── 中间件示意图.jpg ├── init.js ├── readme.md ├── nodemon.json ├── routes │ ├── staticMiddleware.js │ └── errorMiddleware.js ├── mock │ └── mockClass.js └── util │ └── propertyHelper.js ├── 1-9. http模块 ├── public │ ├── script │ │ └── a.js │ ├── css │ │ └── index.css │ └── img │ │ └── u=2770282747,1971577128&fm=26&gp=0.jpg ├── .gitignore └── readme.md ├── 3-3. 模型定义和同步 ├── index.js ├── .gitignore ├── ORM原理图.jpg ├── readme.md └── models │ ├── db.js │ └── sync.js ├── .gitignore ├── 1-11. https模块 ├── public │ ├── script │ │ └── a.js │ ├── css │ │ └── index.css │ └── img │ │ └── u=2770282747,1971577128&fm=26&gp=0.jpg ├── .gitignore ├── ca-cert.srl ├── 演示.pptx └── readme.md ├── 3-10. 数据验证 ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── 三层架构.jpg ├── readme.md ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── index.js ├── 3-4. 模型的增删改 ├── .gitignore ├── 三层架构.jpg ├── readme.md ├── models │ ├── sync.js │ └── db.js └── index.js ├── 3-5. 模拟数据 ├── .gitignore ├── index.js ├── 三层架构.jpg ├── readme.md ├── models │ ├── relation.js │ ├── sync.js │ └── db.js └── mock │ └── mockClass.js ├── 3-6. 数据抓取 ├── .gitignore ├── index.js ├── 三层架构.jpg ├── readme.md ├── models │ ├── relation.js │ ├── sync.js │ └── db.js └── mock │ └── mockClass.js ├── 3-7. 数据查询 ├── .gitignore ├── 三层架构.jpg ├── readme.md ├── models │ ├── relation.js │ ├── sync.js │ └── db.js ├── index.js ├── index copy.js └── mock │ └── mockClass.js ├── 3-8. MD5加密 ├── .gitignore ├── 三层架构.jpg ├── readme.md ├── models │ ├── relation.js │ ├── sync.js │ └── db.js ├── index.js └── mock │ └── mockClass.js ├── 3-9. moment ├── .gitignore ├── 三层架构.jpg ├── 时间处理模式.jpg ├── readme.md ├── models │ ├── relation.js │ ├── sync.js │ └── db.js └── mock │ └── mockClass.js ├── 1-12. node生命周期 ├── .gitignore ├── 课件.pptx ├── readme.md ├── index copy 3.js ├── 面试题1.js ├── index copy 2.js ├── index copy.js └── index.js ├── 3-1. mysql驱动程序 ├── .gitignore └── readme.md ├── 3-11. 访问器和虚拟字段 ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── 三层架构.jpg ├── readme.md ├── mock │ └── mockClass.js └── util │ └── propertyHelper.js ├── 5-6. NodeJS组成原理 ├── index.js ├── .gitignore ├── nodemon.json ├── .vscode │ └── launch.json └── 原理图说明.md ├── 3-12. 日志记录 ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── 三层架构.jpg ├── log等级.jpg ├── readme.md ├── index.js ├── mock │ └── mockClass.js └── util │ └── propertyHelper.js ├── 1-13. [扩展] EventEmitter ├── .gitignore ├── readme.md ├── index.js └── index copy 2.js ├── 4-2. nodemon ├── .gitignore ├── init.js ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── 三层架构.jpg ├── readme.md ├── nodemon.json ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── index.js ├── 4-1. express的基本使用 ├── .gitignore ├── models │ ├── init.js │ ├── relation.js │ ├── sync.js │ └── db.js ├── init.js ├── log等级.jpg ├── 三层架构.jpg ├── readme.md ├── mock │ └── mockClass.js ├── util │ └── propertyHelper.js └── index copy.js ├── NodeJS.xmind ├── 5-5. XSS攻击和防御 ├── .gitignore ├── nodemon.json └── .vscode │ └── launch.json ├── 5-7. 进程和线程 ├── .gitignore ├── isPrime.js ├── nodemon.json ├── index copy 2.js ├── index copy 3.js └── .vscode │ └── launch.json ├── 5-1. websocket原理 ├── .gitignore ├── nodemon.json └── .vscode │ └── launch.json ├── 5-2. socket.io ├── .gitignore ├── nodemon.json └── .vscode │ └── launch.json ├── 5-3. [扩展]在线聊天室 ├── .gitignore ├── nodemon.json └── .vscode │ └── launch.json └── .vscode └── launch.json /index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2-6. 联表查询/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1-10. https协议/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1-7. 文件流/abc.txt: -------------------------------------------------------------------------------- 1 | 渡一abc -------------------------------------------------------------------------------- /2-4. 表记录的增删改/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2-5. 单表基本查询/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /2-7. 函数和分组/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1-6. 文件IO/myfiles/2.txt: -------------------------------------------------------------------------------- 1 | abcde -------------------------------------------------------------------------------- /1-6. 文件IO/myfiles/sub/3.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /3-2. Sequelize简介/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-13. jwt/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-8. 断点调试/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1-2. 全局对象/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /1-6. 文件IO/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /4-10. 跨域之CORS/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-11. CORS中间件/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-11. CORS中间件/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-12. session/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-12. session/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-13. jwt/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/public/1.asaf.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-5. express路由/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-8. 断点调试/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1-5. 基本内置模块/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /1-6. 文件IO/myfiles/1.txt: -------------------------------------------------------------------------------- 1 | abc阿斯顿发发放到发 -------------------------------------------------------------------------------- /1-6. 文件IO/myfiles/1/3.txt: -------------------------------------------------------------------------------- 1 | assafasdf -------------------------------------------------------------------------------- /1-6. 文件IO/myfiles/1/6.txt: -------------------------------------------------------------------------------- 1 | asfasfasdf -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/public/1.asfdasdf.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-5. express路由/routes/api/admin.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-5. express路由/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/routes/api/book.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/routes/api/class.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1-3. Node的模块化细节/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /1-4. 【扩展】Node中的ES模块/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /1-7. 文件流/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-4. 常用中间件/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-8. 断点调试/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /1-8. net模块/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ -------------------------------------------------------------------------------- /4-10. 跨域之CORS/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-11. CORS中间件/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-13. jwt/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | 3 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-3. express中间件/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-5. express路由/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | -------------------------------------------------------------------------------- /1-3. Node的模块化细节/ab.js: -------------------------------------------------------------------------------- 1 | console.log("module ab"); 2 | -------------------------------------------------------------------------------- /1-9. http模块/public/script/a.js: -------------------------------------------------------------------------------- 1 | alert("asfasfd"); 2 | -------------------------------------------------------------------------------- /3-3. 模型定义和同步/index.js: -------------------------------------------------------------------------------- 1 | require("./models/sync"); 2 | -------------------------------------------------------------------------------- /4-12. session/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | 3 | -------------------------------------------------------------------------------- /4-4. 常用中间件/public/js/index.js: -------------------------------------------------------------------------------- 1 | console.log("abc"); 2 | -------------------------------------------------------------------------------- /4-8. 断点调试/public/js/index.js: -------------------------------------------------------------------------------- 1 | console.log("abc"); 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | ~*.ppt* 3 | .DS_Store 4 | 5 | -------------------------------------------------------------------------------- /1-10. https协议/public/script/a.js: -------------------------------------------------------------------------------- 1 | alert("asfasfd"); 2 | -------------------------------------------------------------------------------- /1-11. https模块/public/script/a.js: -------------------------------------------------------------------------------- 1 | alert("asfasfd"); 2 | -------------------------------------------------------------------------------- /1-9. http模块/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~$*.ppt* -------------------------------------------------------------------------------- /2-4. 表记录的增删改/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /2-5. 单表基本查询/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /2-5. 单表基本查询/limit.sql: -------------------------------------------------------------------------------- 1 | SELECT * from employee 2 | limit 2,3; -------------------------------------------------------------------------------- /2-6. 联表查询/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /2-7. 函数和分组/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-10. 数据验证/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-3. 模型定义和同步/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-4. 模型的增删改/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-5. 模拟数据/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-6. 数据抓取/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-7. 数据查询/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-8. MD5加密/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-9. moment/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /4-5. express路由/public/js/index.js: -------------------------------------------------------------------------------- 1 | console.log("abc"); 2 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/public/js/index.js: -------------------------------------------------------------------------------- 1 | console.log("abc"); 2 | -------------------------------------------------------------------------------- /1-10. https协议/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~$*.ppt* -------------------------------------------------------------------------------- /1-11. https模块/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~$*.ppt* -------------------------------------------------------------------------------- /1-12. node生命周期/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /1-3. Node的模块化细节/a.json: -------------------------------------------------------------------------------- 1 | { 2 | "a": 1, 3 | "b": 2 4 | } 5 | -------------------------------------------------------------------------------- /3-1. mysql驱动程序/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /3-2. Sequelize简介/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /4-6. cookie的基本概念/public/js/index.js: -------------------------------------------------------------------------------- 1 | console.log("abc"); 2 | -------------------------------------------------------------------------------- /5-6. NodeJS组成原理/index.js: -------------------------------------------------------------------------------- 1 | console.log(arguments.length); 2 | -------------------------------------------------------------------------------- /2-4. 表记录的增删改/delete.sql: -------------------------------------------------------------------------------- 1 | DELETE FROM student 2 | WHERE `name`='袁哥'; -------------------------------------------------------------------------------- /3-12. 日志记录/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/* -------------------------------------------------------------------------------- /4-4. 常用中间件/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/* -------------------------------------------------------------------------------- /1-11. https模块/ca-cert.srl: -------------------------------------------------------------------------------- 1 | 539DAE571A232A3C5D4DAABD66429E59ACEAA0F9 2 | -------------------------------------------------------------------------------- /1-13. [扩展] EventEmitter/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* -------------------------------------------------------------------------------- /2-4. 表记录的增删改/update.sql: -------------------------------------------------------------------------------- 1 | UPDATE student SET `name`='邓旭名' 2 | WHERE id=12; -------------------------------------------------------------------------------- /4-2. nodemon/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/* -------------------------------------------------------------------------------- /4-3. express中间件/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/* -------------------------------------------------------------------------------- /4-5. express路由/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/* -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | -------------------------------------------------------------------------------- /4-8. 断点调试/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | -------------------------------------------------------------------------------- /1-4. 【扩展】Node中的ES模块/index.mjs: -------------------------------------------------------------------------------- 1 | import("./a.mjs").then(r => console.log(r)); 2 | -------------------------------------------------------------------------------- /3-10. 数据验证/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /3-12. 日志记录/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-1. express的基本使用/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/* -------------------------------------------------------------------------------- /4-10. 跨域之CORS/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-11. CORS中间件/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-12. session/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-13. jwt/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-2. nodemon/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); -------------------------------------------------------------------------------- /4-2. nodemon/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-4. 常用中间件/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-8. 断点调试/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | -------------------------------------------------------------------------------- /NodeJS.xmind: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/NodeJS.xmind -------------------------------------------------------------------------------- /2-6. 联表查询/distinct.sql: -------------------------------------------------------------------------------- 1 | -- 所有员工分布的地址 2 | 3 | select DISTINCT location from employee; -------------------------------------------------------------------------------- /3-10. 数据验证/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /3-12. 日志记录/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | -------------------------------------------------------------------------------- /4-1. express的基本使用/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | not dead 4 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-3. express中间件/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-5. express路由/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/models/init.js: -------------------------------------------------------------------------------- 1 | require("./relation"); 2 | require("./sync"); 3 | -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | -------------------------------------------------------------------------------- /3-5. 模拟数据/index.js: -------------------------------------------------------------------------------- 1 | require("./models/relation"); 2 | require("./mock/mockStudent"); 3 | -------------------------------------------------------------------------------- /3-6. 数据抓取/index.js: -------------------------------------------------------------------------------- 1 | require("./models/relation"); 2 | require("./spider/fetchBooks"); 3 | -------------------------------------------------------------------------------- /4-1. express的基本使用/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /4-11. CORS中间件/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /4-12. session/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /4-13. jwt/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /4-13. jwt/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-8. 断点调试/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /1-8. net模块/hsq.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-8. net模块/hsq.jpg -------------------------------------------------------------------------------- /1-9. http模块/public/css/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #333; 3 | color: #000; 4 | } 5 | -------------------------------------------------------------------------------- /3-10. 数据验证/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-10. 数据验证/三层架构.jpg -------------------------------------------------------------------------------- /3-12. 日志记录/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-12. 日志记录/三层架构.jpg -------------------------------------------------------------------------------- /3-5. 模拟数据/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-5. 模拟数据/三层架构.jpg -------------------------------------------------------------------------------- /3-6. 数据抓取/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-6. 数据抓取/三层架构.jpg -------------------------------------------------------------------------------- /3-7. 数据查询/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-7. 数据查询/三层架构.jpg -------------------------------------------------------------------------------- /3-8. MD5加密/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-8. MD5加密/三层架构.jpg -------------------------------------------------------------------------------- /4-10. 跨域之CORS/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-11. CORS中间件/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-12. session/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | -------------------------------------------------------------------------------- /4-4. 常用中间件/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-4. 常用中间件/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-4. 常用中间件/三层架构.jpg -------------------------------------------------------------------------------- /4-5. express路由/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-8. 断点调试/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-8. 断点调试/三层架构.jpg -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /1-10. https协议/public/css/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #333; 3 | color: #000; 4 | } 5 | -------------------------------------------------------------------------------- /1-10. https协议/演示.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-10. https协议/演示.pptx -------------------------------------------------------------------------------- /1-11. https模块/public/css/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #333; 3 | color: #000; 4 | } 5 | -------------------------------------------------------------------------------- /1-11. https模块/演示.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-11. https模块/演示.pptx -------------------------------------------------------------------------------- /1-12. node生命周期/课件.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-12. node生命周期/课件.pptx -------------------------------------------------------------------------------- /3-12. 日志记录/log等级.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-12. 日志记录/log等级.jpg -------------------------------------------------------------------------------- /3-4. 模型的增删改/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-4. 模型的增删改/三层架构.jpg -------------------------------------------------------------------------------- /3-9. moment/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-9. moment/三层架构.jpg -------------------------------------------------------------------------------- /3-9. moment/时间处理模式.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-9. moment/时间处理模式.jpg -------------------------------------------------------------------------------- /4-10. 跨域之CORS/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-10. 跨域之CORS/三层架构.jpg -------------------------------------------------------------------------------- /4-11. CORS中间件/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-11. CORS中间件/三层架构.jpg -------------------------------------------------------------------------------- /4-12. session/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-12. session/三层架构.jpg -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-2. nodemon/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-2. nodemon/三层架构.jpg -------------------------------------------------------------------------------- /4-4. 常用中间件/中间件示意图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-4. 常用中间件/中间件示意图.jpg -------------------------------------------------------------------------------- /4-6. cookie的基本概念/public/css/index.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #000; 3 | color: #fff; 4 | } -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-7. 实现登陆和认证/三层架构.jpg -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-9. 跨域之JSONP/三层架构.jpg -------------------------------------------------------------------------------- /1-6. 文件IO/myfiles/1.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-6. 文件IO/myfiles/1.jpeg -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-11. 访问器和虚拟字段/三层架构.jpg -------------------------------------------------------------------------------- /3-3. 模型定义和同步/ORM原理图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-3. 模型定义和同步/ORM原理图.jpg -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/new.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-19. 场景 - 图片水印/new.jpg -------------------------------------------------------------------------------- /4-3. express中间件/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-3. express中间件/三层架构.jpg -------------------------------------------------------------------------------- /4-5. express路由/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-5. express路由/三层架构.jpg -------------------------------------------------------------------------------- /3-2. Sequelize简介/ORM原理图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/3-2. Sequelize简介/ORM原理图.jpg -------------------------------------------------------------------------------- /4-1. express的基本使用/log等级.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-1. express的基本使用/log等级.jpg -------------------------------------------------------------------------------- /4-1. express的基本使用/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-1. express的基本使用/三层架构.jpg -------------------------------------------------------------------------------- /4-12. session/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-13. jwt/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/origin.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-19. 场景 - 图片水印/origin.jpg -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-19. 场景 - 图片水印/water.jpg -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/代理服务器.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-21. 重要场景 - 代理/代理服务器.jpg -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/code.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-23. 场景 - 生成二维码/code.png -------------------------------------------------------------------------------- /4-3. express中间件/中间件示意图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-3. express中间件/中间件示意图.jpg -------------------------------------------------------------------------------- /4-6. cookie的基本概念/三层架构.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-6. cookie的基本概念/三层架构.jpg -------------------------------------------------------------------------------- /1-6. 文件IO/myfiles/1.copy.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-6. 文件IO/myfiles/1.copy.jpeg -------------------------------------------------------------------------------- /4-10. 跨域之CORS/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-11. CORS中间件/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/两种渲染方式.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-22. 扩展场景 - 模版引擎/两种渲染方式.jpg -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); -------------------------------------------------------------------------------- /4-4. 常用中间件/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-8. 断点调试/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-12. session/session原理示意图.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-12. session/session原理示意图.jpg -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources -------------------------------------------------------------------------------- /4-3. express中间件/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-5. express路由/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/init.js: -------------------------------------------------------------------------------- 1 | require("./models/init"); 2 | require("./services/init"); 3 | require("./routes/init"); 4 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/public/css/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: #000; 3 | color: #fff; 4 | padding: 20px; 5 | } 6 | -------------------------------------------------------------------------------- /1-4. 【扩展】Node中的ES模块/a.mjs: -------------------------------------------------------------------------------- 1 | export default 5 2 | export const a = 1; 3 | 4 | // exports.b = 3; 5 | // exports.a = 5; 6 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-15. 登录和认证-客户端开发/public/favicon.ico -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-19. 场景 - 图片水印/public/img/water.jpg -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/public/img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-20. 场景 - 图片防盗链/public/img/logo.jpg -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-20. 场景 - 图片防盗链/public/img/water.jpg -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/public/img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-21. 重要场景 - 代理/public/img/logo.jpg -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-21. 重要场景 - 代理/public/img/water.jpg -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/public/img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-22. 扩展场景 - 模版引擎/public/img/logo.jpg -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/public/img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-23. 场景 - 生成二维码/public/img/logo.jpg -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-23. 场景 - 生成二维码/public/img/water.jpg -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/public/img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-24. 场景 - 生成验证码/public/img/logo.jpg -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-24. 场景 - 生成验证码/public/img/water.jpg -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/public/img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-25. 场景 - 客户端缓存/public/img/logo.jpg -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-25. 场景 - 客户端缓存/public/img/water.jpg -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/public/img/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-26. 场景 - 富文本框/public/img/logo.jpg -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-26. 场景 - 富文本框/public/img/water.jpg -------------------------------------------------------------------------------- /1-3. Node的模块化细节/src/index.js: -------------------------------------------------------------------------------- 1 | // console.log("src index module"); 2 | 3 | // console.log(module); 4 | 5 | console.log(require) 6 | -------------------------------------------------------------------------------- /4-13. jwt/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/public/img/water.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-22. 扩展场景 - 模版引擎/public/img/water.jpg -------------------------------------------------------------------------------- /4-4. 常用中间件/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-8. 断点调试/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-10. 跨域之CORS/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-11. CORS中间件/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-12. session/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | resources 8 | public/origin -------------------------------------------------------------------------------- /4-5. express路由/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-6. cookie的基本概念/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /5-5. XSS攻击和防御/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | public/origin 8 | resources 9 | -------------------------------------------------------------------------------- /5-7. 进程和线程/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | public/origin 8 | resources 9 | -------------------------------------------------------------------------------- /2-5. 单表基本查询/order by.sql: -------------------------------------------------------------------------------- 1 | SELECT *, case ismale 2 | when 1 then '男' 3 | else '女' 4 | end sex from employee 5 | ORDER BY sex asc, salary desc; -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/client/readme.md: -------------------------------------------------------------------------------- 1 | 这里面搭建vue工程(react) 2 | 3 | 1. 配置build的路径,把build之后的代码放到../public中 4 | 2. 或者,改动服务器的静态资源目录,改动到client/dist目录中 -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-15. 登录和认证-客户端开发/client/public/favicon.ico -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-15. 登录和认证-客户端开发/client/src/assets/logo.png -------------------------------------------------------------------------------- /5-1. websocket原理/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | public/origin 8 | resources 9 | -------------------------------------------------------------------------------- /5-2. socket.io/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | public/origin 8 | resources 9 | -------------------------------------------------------------------------------- /5-3. [扩展]在线聊天室/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | public/origin 8 | resources 9 | -------------------------------------------------------------------------------- /5-6. NodeJS组成原理/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | temp/ 3 | ~*.ppt* 4 | logs/ 5 | .DS_Store 6 | public/upload 7 | public/origin 8 | resources 9 | -------------------------------------------------------------------------------- /1-7. 文件流/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/public/img/logo.82b9c7a5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/4-15. 登录和认证-客户端开发/public/img/logo.82b9c7a5.png -------------------------------------------------------------------------------- /1-10. https协议/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-11. https模块/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-2. 全局对象/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-5. 基本内置模块/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-6. 文件IO/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-8. net模块/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-9. http模块/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /2-4. 表记录的增删改/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /2-5. 单表基本查询/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /2-6. 联表查询/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /2-7. 函数和分组/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-10. 数据验证/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-12. 日志记录/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-3. 模型定义和同步/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-4. 模型的增删改/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-5. 模拟数据/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-6. 数据抓取/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-7. 数据查询/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-8. MD5加密/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-9. moment/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-12. node生命周期/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-3. Node的模块化细节/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-1. mysql驱动程序/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /3-2. Sequelize简介/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /4-1. express的基本使用/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/src/views/Protect.vue: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /1-13. [扩展] EventEmitter/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-2. 全局对象/src/index.js: -------------------------------------------------------------------------------- 1 | // const buffer = Buffer.from("abcdefg", "utf-8"); 2 | // console.log(buffer); 3 | // console.log("当前命令行:", process.cwd()); 4 | 5 | 6 | -------------------------------------------------------------------------------- /1-4. 【扩展】Node中的ES模块/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` -------------------------------------------------------------------------------- /1-12. node生命周期/index copy 3.js: -------------------------------------------------------------------------------- 1 | setTimeout(() => { 2 | console.log("setTimeout"); 3 | }, 0); 4 | 5 | setImmediate(() => { 6 | console.log("setImmediate"); 7 | }); 8 | -------------------------------------------------------------------------------- /4-2. nodemon/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` 10 | -------------------------------------------------------------------------------- /4-4. 常用中间件/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` 10 | -------------------------------------------------------------------------------- /1-9. http模块/public/img/u=2770282747,1971577128&fm=26&gp=0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-9. http模块/public/img/u=2770282747,1971577128&fm=26&gp=0.jpg -------------------------------------------------------------------------------- /2-7. 函数和分组/数学函数.sql: -------------------------------------------------------------------------------- 1 | SELECT ABS(-1); 2 | SELECT CEIL(1.4); 3 | SELECT ROUND(3.1415926, 3); 4 | SELECT TRUNCATE(3.1415926,3); 5 | 6 | SELECT TRUNCATE(salary,0) 7 | FROM employee -------------------------------------------------------------------------------- /3-12. 日志记录/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | 3 | const stuServ = require("./services/studentService"); 4 | stuServ.getStudents().then((r) => { 5 | console.log(r); 6 | }); 7 | -------------------------------------------------------------------------------- /4-3. express中间件/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` 10 | -------------------------------------------------------------------------------- /4-5. express路由/readme.md: -------------------------------------------------------------------------------- 1 | 每一节课都是一个分支,分支名为课程名称编号 2 | 3 | 要切换到相应的课程,仅需切换分支即可 4 | 5 | 例如要切换到第一章第一节课,运行下面的命令即可: 6 | 7 | ```shell 8 | git checkout 1-1 9 | ``` 10 | -------------------------------------------------------------------------------- /1-10. https协议/public/img/u=2770282747,1971577128&fm=26&gp=0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-10. https协议/public/img/u=2770282747,1971577128&fm=26&gp=0.jpg -------------------------------------------------------------------------------- /1-11. https模块/public/img/u=2770282747,1971577128&fm=26&gp=0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DuYi-Edu/DuYi-Node/HEAD/1-11. https模块/public/img/u=2770282747,1971577128&fm=26&gp=0.jpg -------------------------------------------------------------------------------- /1-12. node生命周期/面试题1.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | fs.readFile("./index.js", () => { 3 | setTimeout(() => console.log(1), 0); 4 | setImmediate(() => console.log(2)); 5 | }); 6 | -------------------------------------------------------------------------------- /3-10. 数据验证/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /3-12. 日志记录/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /3-5. 模拟数据/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /3-6. 数据抓取/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /3-7. 数据查询/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /3-8. MD5加密/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /3-9. moment/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-13. jwt/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-2. nodemon/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-4. 常用中间件/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-8. 断点调试/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-1. express的基本使用/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-11. CORS中间件/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-12. session/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-3. express中间件/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-5. express路由/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/models/relation.js: -------------------------------------------------------------------------------- 1 | // 设置模型关系 2 | const Class = require("./Class"); 3 | const Student = require("./Student"); 4 | Class.hasMany(Student); 5 | Student.belongsTo(Class); 6 | -------------------------------------------------------------------------------- /4-13. jwt/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | -------------------------------------------------------------------------------- /4-8. 断点调试/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-11. CORS中间件/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-12. session/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-2. nodemon/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-4. 常用中间件/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-5. express路由/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-3. express中间件/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": ["package*.json", "client", "nodemon.json", "node_modules", "public"] 7 | } 8 | -------------------------------------------------------------------------------- /1-12. node生命周期/index copy 2.js: -------------------------------------------------------------------------------- 1 | let i = 0; 2 | console.time(); 3 | function test() { 4 | i++; 5 | if (i < 1000) { 6 | setImmediate(test); 7 | } else { 8 | console.timeEnd(); 9 | } 10 | } 11 | 12 | test(); 13 | -------------------------------------------------------------------------------- /3-7. 数据查询/index.js: -------------------------------------------------------------------------------- 1 | require("./models/relation"); 2 | // require("./spider/fetchBooks"); 3 | const stuServ = require("./services/studentService"); 4 | stuServ.getStudents(1, 10, false, "秀").then((r) => { 5 | console.log(r); 6 | }); 7 | -------------------------------------------------------------------------------- /1-3. Node的模块化细节/myModule.js: -------------------------------------------------------------------------------- 1 | console.log("当前模块路径:", __dirname); 2 | console.log("当前模块文件:", __filename); 3 | exports.c = 3; 4 | module.exports = { 5 | a: 1, 6 | b: 2 7 | }; 8 | this.m = 5; 9 | 10 | console.log(this === exports); 11 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import loginUser from "./loginUser" 4 | 5 | Vue.use(Vuex) 6 | 7 | export default new Vuex.Store({ 8 | modules: { 9 | loginUser 10 | } 11 | }) 12 | -------------------------------------------------------------------------------- /2-7. 函数和分组/聚合函数.sql: -------------------------------------------------------------------------------- 1 | SELECT AVG(salary) as `avg`, id 2 | FROM employee; 3 | 4 | -- 查询员工数量 5 | SELECT COUNT(id) 6 | FROM employee; 7 | 8 | SELECT count(id) as 员工数量, 9 | avg(salary) as 平均薪资, 10 | sum(salary) as 总薪资, 11 | min(salary) as 最小薪资 12 | FROM employee; 13 | -------------------------------------------------------------------------------- /3-10. 数据验证/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-12. 日志记录/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-5. 模拟数据/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-6. 数据抓取/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-7. 数据查询/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-8. MD5加密/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-13. jwt/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-4. 常用中间件/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-8. 断点调试/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /1-6. 文件IO/fs.mkdir.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | const dirname = path.resolve(__dirname, "./myfiles/1"); 4 | async function test() { 5 | await fs.promises.mkdir(dirname); 6 | console.log("创建目录成功"); 7 | } 8 | 9 | test(); 10 | -------------------------------------------------------------------------------- /3-10. 数据验证/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-3. 模型定义和同步/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-3. 模型定义和同步/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-4. 模型的增删改/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /3-5. 模拟数据/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | // logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-6. 数据抓取/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | // logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-7. 数据查询/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | // logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-8. MD5加密/index.js: -------------------------------------------------------------------------------- 1 | require("./models/relation"); 2 | 3 | const adminServ = require("./services/adminService"); 4 | // adminServ.updateAdmin(7, { 5 | // loginPwd: "123", 6 | // }); 7 | adminServ.login("bcd", "123").then((r) => { 8 | console.log(r); 9 | }); 10 | -------------------------------------------------------------------------------- /3-8. MD5加密/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | // logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-9. moment/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-11. CORS中间件/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-12. session/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-2. nodemon/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/index.js: -------------------------------------------------------------------------------- 1 | // require("./init"); 2 | const QRCode = require("qrcode"); 3 | QRCode.toDataURL("https://duyi.ke.qq.com/?tuin=a5d48d54", (err, url) => { 4 | if (err) { 5 | console.log(err); 6 | } else { 7 | console.log(url); 8 | } 9 | }); 10 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-3. express中间件/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-5. express路由/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /5-7. 进程和线程/isPrime.js: -------------------------------------------------------------------------------- 1 | module.exports = function (n) { 2 | // 素数:只能被1和自身整除的数 3 | if (n < 2) { 4 | return false; 5 | } 6 | for (let i = 2; i < n; i++) { 7 | if (n % i === 0) { 8 | return false; 9 | } 10 | } 11 | return true; 12 | }; 13 | -------------------------------------------------------------------------------- /5-7. 进程和线程/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": [ 7 | "package*.json", 8 | "client", 9 | "nodemon.json", 10 | "node_modules", 11 | "public" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-4. 模型的增删改/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | // logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /3-9. moment/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | // logging: null 7 | }); 8 | 9 | module.exports = sequelize; 10 | -------------------------------------------------------------------------------- /4-1. express的基本使用/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/models/sync.js: -------------------------------------------------------------------------------- 1 | // 同步所有模型 2 | require("./Admin"); 3 | require("./Book"); 4 | require("./Class"); 5 | require("./Student"); 6 | const sequelize = require("./db"); 7 | sequelize.sync({ alter: true }).then(() => { 8 | console.log("所有模型同步完成"); 9 | }); 10 | -------------------------------------------------------------------------------- /5-1. websocket原理/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": [ 7 | "package*.json", 8 | "client", 9 | "nodemon.json", 10 | "node_modules", 11 | "public" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /5-2. socket.io/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": [ 7 | "package*.json", 8 | "client", 9 | "nodemon.json", 10 | "node_modules", 11 | "public" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /5-3. [扩展]在线聊天室/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": [ 7 | "package*.json", 8 | "client", 9 | "nodemon.json", 10 | "node_modules", 11 | "public" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /5-5. XSS攻击和防御/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": [ 7 | "package*.json", 8 | "client", 9 | "nodemon.json", 10 | "node_modules", 11 | "public" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /5-6. NodeJS组成原理/nodemon.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "NODE_ENV": "development" 4 | }, 5 | "watch": ["*.js", "*.json"], 6 | "ignore": [ 7 | "package*.json", 8 | "client", 9 | "nodemon.json", 10 | "node_modules", 11 | "public" 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /1-13. [扩展] EventEmitter/index.js: -------------------------------------------------------------------------------- 1 | const MyRequest = require("./MyRequest"); 2 | 3 | const request = new MyRequest("http://duyi.ke.qq.com"); 4 | 5 | request.send(); 6 | 7 | request.on("res", (headers, body) => { 8 | console.log(headers); 9 | console.log(body); 10 | }); 11 | -------------------------------------------------------------------------------- /1-6. 文件IO/fs.readdir.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | const dirname = path.resolve(__dirname, "./myfiles/"); 4 | async function test() { 5 | const pathes = await fs.promises.readdir(dirname); 6 | console.log(pathes); 7 | } 8 | 9 | test(); 10 | -------------------------------------------------------------------------------- /1-13. [扩展] EventEmitter/index copy 2.js: -------------------------------------------------------------------------------- 1 | const { EventEmitter } = require("events"); 2 | // 创建一个事件处理对象 3 | // 可以注册事件,可以触发事件 4 | const ee = new EventEmitter(); 5 | 6 | ee.on("abc", (data1, data2) => { 7 | console.log("abc事件触发了", data1, data2); 8 | }); 9 | 10 | ee.emit("abc", 123, 456) -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/public/css/app.5c9713c3.css: -------------------------------------------------------------------------------- 1 | #app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-align:center;color:#2c3e50}#nav{padding:30px}#nav a{font-weight:700;color:#2c3e50}#nav a.router-link-exact-active{color:#42b983} -------------------------------------------------------------------------------- /5-7. 进程和线程/index copy 2.js: -------------------------------------------------------------------------------- 1 | const { Worker } = require("worker_threads"); 2 | const path = require("path"); 3 | const worker = new Worker(path.resolve(__dirname, "worker.js"), { 4 | workerData: 123, 5 | }); // worker是子线程实例 6 | worker.on("exit", () => { 7 | console.log("子线程退出了"); 8 | }); 9 | -------------------------------------------------------------------------------- /5-7. 进程和线程/index copy 3.js: -------------------------------------------------------------------------------- 1 | const isPrime = require("./isPrime"); 2 | const arr = require("./numbers.json") 3 | console.time(); 4 | const newArr = []; 5 | for (const n of arr) { 6 | if (isPrime(n)) { 7 | newArr.push(n); 8 | } 9 | } 10 | console.timeEnd(); 11 | console.log(newArr); 12 | -------------------------------------------------------------------------------- /1-3. Node的模块化细节/index copy.js: -------------------------------------------------------------------------------- 1 | // require("D:\\repository\\NodeJS\\源码\\a.js"); 2 | // const result = require("./ab"); 3 | // console.log(result); 4 | 5 | // require("abc"); 6 | 7 | // require("./src"); 8 | 9 | // require("abc/index") 10 | 11 | // require("./src"); 12 | 13 | require("./src") 14 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/vue.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | 3 | module.exports = { 4 | devServer: { 5 | proxy: { 6 | "/api": { 7 | target: "http://localhost:5008", 8 | }, 9 | }, 10 | }, 11 | outputDir: path.resolve(__dirname, "../public"), 12 | }; 13 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /3-7. 数据查询/index copy.js: -------------------------------------------------------------------------------- 1 | require("./models/relation"); 2 | // require("./spider/fetchBooks"); 3 | const adminServ = require("./services/adminService"); 4 | // adminServ.login("bcd", "abc").then((r) => { 5 | // console.log(r); 6 | // }); 7 | adminServ.getAdminById(1).then((r) => { 8 | console.log(r); 9 | }); 10 | -------------------------------------------------------------------------------- /4-3. express中间件/routes/staticMiddleware.js: -------------------------------------------------------------------------------- 1 | module.exports = (req, res, next) => { 2 | if (req.path.startsWith("/api")) { 3 | // 说明你请求的是 api 接口 4 | next(); 5 | } else { 6 | // 说明你想要的是静态资源 7 | if (true) { 8 | res.send("静态资源"); 9 | } else { 10 | next(); 11 | } 12 | } 13 | }; 14 | -------------------------------------------------------------------------------- /2-7. 函数和分组/字符串和日期函数.sql: -------------------------------------------------------------------------------- 1 | SELECT CONCAT_WS('@', `name`,salary) 2 | FROM employee; 3 | 4 | SELECT CURDATE(); 5 | 6 | SELECT CURTIME(); 7 | 8 | SELECT TIMESTAMPDIFF(DAY,'2010-1-1 11:11:11','2010-1-2 11:11:12'); 9 | 10 | SELECT *, 11 | TIMESTAMPDIFF(YEAR, birthday, CURDATE()) as age 12 | from employee 13 | ORDER BY age; -------------------------------------------------------------------------------- /3-5. 模拟数据/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /3-6. 数据抓取/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /3-7. 数据查询/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-13. jwt/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-8. 断点调试/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /3-10. 数据验证/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /3-10. 数据验证/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /3-12. 日志记录/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /3-12. 日志记录/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /3-8. MD5加密/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /3-9. moment/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-11. CORS中间件/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-12. session/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-13. jwt/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-2. nodemon/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-2. nodemon/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-4. 常用中间件/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-4. 常用中间件/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-5. express路由/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-8. 断点调试/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /1-5. 基本内置模块/about os.js: -------------------------------------------------------------------------------- 1 | const os = require("os"); 2 | 3 | // console.log(os.EOL); 4 | 5 | // console.log(os.arch()) 6 | 7 | // console.log(os.cpus().length); 8 | 9 | // console.log(os.freemem() / 2 ** 30); 10 | 11 | // console.log(os.homedir()); 12 | 13 | // console.log(os.hostname()); 14 | 15 | console.log(os.tmpdir()); 16 | -------------------------------------------------------------------------------- /3-11. 访问器和虚拟字段/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-1. express的基本使用/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-1. express的基本使用/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-11. CORS中间件/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-12. session/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-3. express中间件/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-3. express中间件/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-5. express路由/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/mock/mockClass.js: -------------------------------------------------------------------------------- 1 | const Mock = require("mockjs"); 2 | const result = Mock.mock({ 3 | "datas|16": [ 4 | { 5 | "id|+1": 1, 6 | name: "前端第 @id 期", 7 | openDate: "@date", 8 | }, 9 | ], 10 | }).datas; 11 | 12 | const Class = require("../models/Class"); 13 | Class.bulkCreate(result); 14 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/util/propertyHelper.js: -------------------------------------------------------------------------------- 1 | exports.pick = function (obj, ...props) { 2 | if (!obj || typeof obj !== "object") { 3 | return obj; 4 | } 5 | const newObj = {}; 6 | for (const key in obj) { 7 | if (props.includes(key)) { 8 | newObj[key] = obj[key]; 9 | } 10 | } 11 | return newObj; 12 | }; 13 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/test.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |

10 | 数字: <%= number %> 11 |

12 | 13 | 14 | -------------------------------------------------------------------------------- /4-4. 常用中间件/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = { 6 | code: 500, 7 | msg: err instanceof Error ? err.message : err, 8 | }; 9 | //发生了错误 10 | res.status(500).send(errObj); 11 | } else { 12 | next(); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "启动程序", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-13. jwt/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-2. nodemon/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | const express = require("express"); 3 | const app = express(); //创建一个express应用 4 | console.log(process.env.NODE_ENV); 5 | app.get("*", (req, res) => { 6 | res.send("abc123"); 7 | }); 8 | 9 | const port = 5008; 10 | app.listen(port, () => { 11 | console.log(`server listen on ${port}`); 12 | }); 13 | -------------------------------------------------------------------------------- /4-3. express中间件/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = { 6 | code: 500, 7 | msg: err instanceof Error ? err.message : err, 8 | }; 9 | //发生了错误 10 | res.status(500).send(errObj); 11 | } else { 12 | next(); 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-8. 断点调试/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-11. CORS中间件/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-12. session/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-5. express路由/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/routes/errorMiddleware.js: -------------------------------------------------------------------------------- 1 | // 处理错误的中间件 2 | const getMsg = require("./getSendResult"); 3 | module.exports = (err, req, res, next) => { 4 | if (err) { 5 | const errObj = err instanceof Error ? err.message : err; 6 | //发生了错误 7 | res.status(500).send(getMsg.getErr(errObj)); 8 | } else { 9 | next(); 10 | } 11 | }; 12 | -------------------------------------------------------------------------------- /3-12. 日志记录/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-1. express的基本使用/index copy.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | const express = require("express"); 3 | const http = require("http"); 4 | const app = express(); //创建一个express应用 5 | // app实际上是一个函数,用于处理请求的函数 6 | const server = http.createServer(app); 7 | const port = 5008; 8 | server.listen(port, () => { 9 | console.log(`server listen on ${port}`); 10 | }); 11 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-11. CORS中间件/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-12. session/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-13. jwt/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-2. nodemon/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-4. 常用中间件/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-7. 实现登陆和认证/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-8. 断点调试/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /5-7. 进程和线程/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "启动程序", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /2-7. 函数和分组/分组.sql: -------------------------------------------------------------------------------- 1 | -- 查询员工分布的居住地,以及每个居住地有多少名员工 2 | -- 天府三街 3 3 | SELECT location, count(id) as empnumber 4 | FROM employee 5 | GROUP BY location 6 | HAVING empnumber>=40 7 | 8 | -- 查询所有薪水在10000以上的员工的分布的居住地,然后仅得到聚集地大于30的结果 9 | SELECT location, count(id) as empnumber 10 | FROM employee 11 | WHERE salary>=10000 12 | GROUP BY location 13 | HAVING count(id)>=30 14 | -------------------------------------------------------------------------------- /4-1. express的基本使用/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-11. CORS中间件/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-12. session/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-13. jwt/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/routes/apiLoggerMid.js: -------------------------------------------------------------------------------- 1 | const { apiLogger } = require("../logger.js"); 2 | const log4js = require("log4js"); 3 | 4 | // module.exports = (req, res, next) => { 5 | // next(); 6 | // apiLogger.debug(`${req.method} ${req.path} ${req.ip}`); 7 | // }; 8 | 9 | module.exports = log4js.connectLogger(apiLogger, { 10 | level: "auto", 11 | }); 12 | -------------------------------------------------------------------------------- /4-3. express中间件/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-5. express路由/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-6. cookie的基本概念/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /4-8. 断点调试/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /5-2. socket.io/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "启动程序", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /5-3. [扩展]在线聊天室/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "启动程序", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/models/db.js: -------------------------------------------------------------------------------- 1 | const { Sequelize } = require("sequelize"); 2 | const { sqlLogger } = require("../logger"); 3 | const sequelize = new Sequelize("myschooldb", "root", "ybybdwyJ42.", { 4 | host: "localhost", 5 | dialect: "mysql", 6 | logging: (msg) => { 7 | sqlLogger.debug(msg); 8 | }, 9 | }); 10 | 11 | module.exports = sequelize; 12 | -------------------------------------------------------------------------------- /5-5. XSS攻击和防御/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "启动程序", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /5-6. NodeJS组成原理/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "启动程序", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /1-12. node生命周期/index copy.js: -------------------------------------------------------------------------------- 1 | const start = Date.now(); 2 | setTimeout(function f1() { 3 | console.log("setTimeout", Date.now() - start); 4 | }, 200); 5 | 6 | const fs = require("fs"); 7 | 8 | fs.readFile("./index.js", "utf-8", function f2() { 9 | console.log("readFile"); 10 | const start = Date.now(); 11 | while (Date.now() - start < 300) {} 12 | }); 13 | -------------------------------------------------------------------------------- /1-6. 文件IO/fs.stat.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const path = require("path"); 3 | const filename = path.resolve(__dirname, "./myfiles/"); 4 | async function test() { 5 | const stat = await fs.promises.stat(filename); 6 | console.log(stat); 7 | console.log("是否是目录", stat.isDirectory()); 8 | console.log("是否是文件", stat.isFile()); 9 | } 10 | 11 | test(); 12 | -------------------------------------------------------------------------------- /4-14. 登录和认证-服务器开发/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-16. 场景 - 日志记录/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-17. 场景 - 文件上传/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "调试node", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /5-1. websocket原理/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // 使用 IntelliSense 了解相关属性。 3 | // 悬停以查看现有属性的描述。 4 | // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "attach", 10 | "name": "启动程序", 11 | "port": 9229 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /1-12. node生命周期/index.js: -------------------------------------------------------------------------------- 1 | setImmediate(() => { 2 | console.log(1); 3 | }); 4 | 5 | process.nextTick(() => { 6 | console.log(2); 7 | process.nextTick(() => { 8 | console.log(6); 9 | }); 10 | }); 11 | 12 | console.log(3); 13 | 14 | Promise.resolve().then(() => { 15 | console.log(4); 16 | process.nextTick(() => { 17 | console.log(5); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /1-2. 全局对象/index.js: -------------------------------------------------------------------------------- 1 | // console.log(__dirname); 2 | 3 | // console.log("当前命令行:", process.cwd()); 4 | 5 | // setTimeout(() => { 6 | // console.log("abc"); 7 | // }, 1000); 8 | 9 | // process.exit(); 10 | 11 | // console.log(process.argv); 12 | 13 | // console.log(process.platform); 14 | 15 | // process.kill(10428); 16 | 17 | console.log(process.env.ANDROID_HOME); 18 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from "vue"; 2 | import App from "./App.vue"; 3 | import router from "./router"; 4 | import store from "./store"; 5 | store.dispatch("loginUser/whoAmI"); //在网站被访问时,需要用token去换取用户的身份 6 | 7 | Vue.config.productionTip = false; 8 | 9 | new Vue({ 10 | router, 11 | store, 12 | render: (h) => h(App), 13 | }).$mount("#app"); 14 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/routes/proxyMid.js: -------------------------------------------------------------------------------- 1 | const { createProxyMiddleware } = require("http-proxy-middleware"); 2 | const context = "/data"; 3 | module.exports = createProxyMiddleware(context, { 4 | target: "http://yuanjin.tech:5100", 5 | pathRewrite: function (path, req) { 6 | console.log(path.substr(context.length)); 7 | return path.substr(context.length); 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/routes/proxyMid.js: -------------------------------------------------------------------------------- 1 | const { createProxyMiddleware } = require("http-proxy-middleware"); 2 | const context = "/data"; 3 | module.exports = createProxyMiddleware(context, { 4 | target: "http://yuanjin.tech:5100", 5 | pathRewrite: function (path, req) { 6 | console.log(path.substr(context.length)); 7 | return path.substr(context.length); 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/routes/proxyMid.js: -------------------------------------------------------------------------------- 1 | const { createProxyMiddleware } = require("http-proxy-middleware"); 2 | const context = "/data"; 3 | module.exports = createProxyMiddleware(context, { 4 | target: "http://yuanjin.tech:5100", 5 | pathRewrite: function (path, req) { 6 | console.log(path.substr(context.length)); 7 | return path.substr(context.length); 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/routes/proxyMid.js: -------------------------------------------------------------------------------- 1 | const { createProxyMiddleware } = require("http-proxy-middleware"); 2 | const context = "/data"; 3 | module.exports = createProxyMiddleware(context, { 4 | target: "http://yuanjin.tech:5100", 5 | pathRewrite: function (path, req) { 6 | console.log(path.substr(context.length)); 7 | return path.substr(context.length); 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/routes/proxyMid.js: -------------------------------------------------------------------------------- 1 | const { createProxyMiddleware } = require("http-proxy-middleware"); 2 | const context = "/data"; 3 | module.exports = createProxyMiddleware(context, { 4 | target: "http://yuanjin.tech:5100", 5 | pathRewrite: function (path, req) { 6 | console.log(path.substr(context.length)); 7 | return path.substr(context.length); 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/routes/proxyMid.js: -------------------------------------------------------------------------------- 1 | const { createProxyMiddleware } = require("http-proxy-middleware"); 2 | const context = "/data"; 3 | module.exports = createProxyMiddleware(context, { 4 | target: "http://yuanjin.tech:5100", 5 | pathRewrite: function (path, req) { 6 | console.log(path.substr(context.length)); 7 | return path.substr(context.length); 8 | }, 9 | }); 10 | -------------------------------------------------------------------------------- /4-10. 跨域之CORS/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /4-11. CORS中间件/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /4-15. 登录和认证-客户端开发/client/readme.md: -------------------------------------------------------------------------------- 1 | # client 2 | 3 | ## Project setup 4 | ``` 5 | npm install 6 | ``` 7 | 8 | ### Compiles and hot-reloads for development 9 | ``` 10 | npm run serve 11 | ``` 12 | 13 | ### Compiles and minifies for production 14 | ``` 15 | npm run build 16 | ``` 17 | 18 | ### Customize configuration 19 | See [Configuration Reference](https://cli.vuejs.org/config/). 20 | -------------------------------------------------------------------------------- /4-9. 跨域之JSONP/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /3-10. 数据验证/index.js: -------------------------------------------------------------------------------- 1 | require("./init"); 2 | 3 | const stuServ = require("./services/studentService"); 4 | stuServ 5 | .addStudent({ 6 | name: "adfd", 7 | birthday: "2010-3-5", 8 | sex: true, 9 | mobile: "15454545444", 10 | ClassId: 3, 11 | deletedAt: "2010-1-1", 12 | a: 3, 13 | b: 4, 14 | }) 15 | .catch((err) => { 16 | console.log(err); 17 | }); 18 | -------------------------------------------------------------------------------- /2-6. 联表查询/join.sql: -------------------------------------------------------------------------------- 1 | SELECT * 2 | from department as d left join employee as e 3 | on d.id = e.deptId; 4 | 5 | SELECT * 6 | from employee as e right join department as d 7 | on d.id = e.deptId; 8 | 9 | SELECT e.`name` as empname, d.`name` as dptname, c.`name` as companyname 10 | from employee as e 11 | inner join department as d on d.id = e.deptId 12 | inner join company c on d.companyId = c.id; -------------------------------------------------------------------------------- /5-4. CSRF攻击和防御/danger/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 |

这是一个看上去极其正常的网页

10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 |

你好

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /4-4. 常用中间件/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 |

静态页面

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /4-18. 场景 - 文件下载/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-19. 场景 - 图片水印/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-20. 场景 - 图片防盗链/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-21. 重要场景 - 代理/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-22. 扩展场景 - 模版引擎/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-23. 场景 - 生成二维码/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-24. 场景 - 生成验证码/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-25. 场景 - 客户端缓存/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-26. 场景 - 富文本框/routes/api/download.js: -------------------------------------------------------------------------------- 1 | const express = require("express"); 2 | const path = require("path"); 3 | const router = express.Router(); 4 | 5 | router.get("/:filename", (req, res) => { 6 | const absPath = path.resolve( 7 | __dirname, 8 | "../../resources", 9 | req.params.filename 10 | ); 11 | res.download(absPath, req.params.filename); 12 | }); 13 | 14 | module.exports = router; 15 | -------------------------------------------------------------------------------- /4-5. express路由/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Document 7 | 8 | 9 | 10 |

静态页面

11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /5-6. NodeJS组成原理/原理图说明.md: -------------------------------------------------------------------------------- 1 | ![](http://mdrs.yuanjin.tech/img/node组成原理图.jpg) 2 | 3 | 1. 用户代码 4 | 5 | JS代码,开发者编写的 6 | 7 | 8 | 9 | 2. 第三方库 10 | 11 | 大部分仍然是JS代码,由其他开发者编写 12 | 13 | 14 | 15 | 3. 本地模块代码 16 | 17 | JS代码 18 | 19 | 20 | 21 | 4. V8引擎 22 | 23 | c/c++代码,作用:把JS代码解释成为机器码 24 | 25 | 可以通过v8引擎的某种机制,扩展其功能 26 | 27 | 28 | 29 | V8引擎的扩展和对扩展的编译,是通过一个工具:gyp工具 30 | 31 | 某些第三方库需要使用`node-gyp`工具进行构建,因此需要先安装`node-gyp` -------------------------------------------------------------------------------- /3-4. 模型的增删改/index.js: -------------------------------------------------------------------------------- 1 | const adminServ = require("./services/adminService"); 2 | // adminServ.addAdmin({ 3 | // loginId: "asdfasdfasdfssa", 4 | // loginPwd: "adsfasdfd", 5 | // }); 6 | 7 | adminServ.deleteAdmin(4).then((r) => { 8 | console.log(r); 9 | }); 10 | 11 | // adminServ 12 | // .updateAdmin(4, { 13 | // loginId: "aaaaaa", 14 | // }) 15 | // .then((r) => { 16 | // console.log(r); 17 | // }); 18 | --------------------------------------------------------------------------------