简体中文 | English
nodejs-back-template是一个可快速搭建nodejs接口服务的一个极简框架,由webpack进行压缩打包,封装了websocket、httpserve、file操作、mysql访问等方法,有完整的接口路由系统。
npm install
- npm run watch 可以实时监听文件变化动态更新dist/main.js环境为development
- npm run serve 运行dist/main.js
- npm run build 打包至dist/main.js环境为production
- npm run lint 检测并修复eslint问题
- Fork 本仓库
- 新建 Feat_xxx 分支
- 提交代码
- 新建 Pull Request
- server封装
- ws封装
- 单独的入口main.js
- 层层传递的ws 接口调用时可操作ws对象,ws内socketList为所有已建立连接的用户的socket对象
- 统一的路由管理
- 统一的请求参数读取
- token拦截
MIT License
Copyright (c) 2023 梓齐
软件架构说明
|-- nodejs-template-back
|-- src
| |-- main.js 主函数
| |-- serve.js 服务封装
| |-- common 常量和公共方法
| | |-- BaseResponse.js 请求返回封装
| | |-- CONSTANT
| | |-- index.js 常量主入口,自动化导入所有模块
| | |-- modules
| | |-- RESPONSE.js 请求code常量
| | |-- WHITEURL.js 接口白名单
| |-- config
| | |-- config.development.js 开发环境设置
| | |-- config.js 公用环境设置
| | |-- config.production.js 生产环境设置
| | |-- index.js 主入口根据环境导入config
| |-- controller
| | |-- user.js
| |-- dao
| | |-- db.js
| | |-- modules
| | |-- user.js
| |-- service
| | |-- user.js
| |-- utils
| | |-- auth.js 权限操作
| | |-- file.js 文件操作
| | |-- lock.js 锁
| | |-- router.js 路由类
| |-- webSocket
| | |-- index.js
| | |-- WsResponse.js ws返回值总入口封装
| |-- |-- distribute 事件分发
| | |-- index.js 事件分发主入口,自动化导入modules下所有模块
| | |-- modules
| | |-- user.js
|-- .eslintrc.js
|-- webpack.config.js webpack配置