# node-express-server **Repository Path**: zmmlet/node-express-server ## Basic Information - **Project Name**: node-express-server - **Description**: 基于Node.js的express框架,结合Mysql的服务端项目,实现了用户登录,修改密码,退出登录,修改用户头像,上传,增删改查文章等 - **Primary Language**: NodeJS - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://gitee.com/zmmlet - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 2 - **Created**: 2021-02-23 - **Last Updated**: 2025-08-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: Node, Express, MySQL, Nestjs ## README # 接口文档 # 初始化 ## 环境 - Node.js 14.15.4 - npm 6.14.10 - MySql 5.7.13 ## 安装依赖 `npm install` or `yarn install` ## 运行 `node app.js` # 接口 ## 模拟验证码发送 请求路径:http://localhost:3022/users/sendCode 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |phone|手机号|18790254445|true| **返回结果:** ```json { "code": "200", "message": "发送成功", "verificationCode": 1879 } ``` ## 验证码登录 请求路径:http://localhost:3022/users/codePhoneLogin 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |phone|手机号|18790254445|true| |code|验证码|7721|true| **返回结果:** ```json { "code": 200, "message": "登录成功", "data": { "id": 1, "username": "zmm", "userpic": "https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/05489ead0d0a573504e261a9d24bd352~300x300.image", "password": "123456", "phone": "18790254445", "email": "321300@qq.com", "status": "1", "create_time": 1613965193977, "userinfo": [ { "age": { "type": "Buffer", "data": [50, 48] }, "sex": "1", "job": "前端工程师", "path": "郑州", "birthday": "454545" }, { "age": { "type": "Buffer", "data": [49, 56] }, "sex": "1", "job": "未设置", "path": null, "birthday": null } ] } } ``` ## 用户名密码登陆 请求路径:http://localhost:3022/users/login 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |username|用户名|18790254445|true| |password|密码|123456|true| **返回结果:** ```json { "code": 200, "message": "登录成功", "data": { "id": 1, "username": "zmm", "userpic": "https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/05489ead0d0a573504e261a9d24bd352~300x300.image", "password": "123456", "phone": "18790254445", "email": "321300@qq.com", "status": "1", "create_time": 1613965193977, "userinfo": { "age": { "type": "Buffer", "data": [50, 48] }, "sex": "1", "job": "前端工程师", "path": "郑州", "birthday": "454545" } } } ``` ## 修改用户资料 请求路径:http://localhost:3022/users/editUserInfo 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |user_id|用户 id|1|true| |username|用户名称|zmm|true| |age|用户名称|zmm|true| |sex|1|0 女,1 男|true| |job|工作|前端工程师|true| |path|||true| |birthday|||true| **返回结果:** ```json { "code": 200, "message": "修改成功", "data": { "id": 1, "username": "zmm", "userpic": "https://sf1-ttcdn-tos.pstatp.com/img/user-avatar/05489ead0d0a573504e261a9d24bd352~300x300.image", "password": "123456", "phone": "18790254445", "email": "321300@qq.com", "status": "1", "create_time": 1613965193977, "userinfo": { "age": { "type": "Buffer", "data": [50, 48] }, "sex": "1", "job": "前端工程师", "path": "郑州", "birthday": "454545" } } } ``` ## 修改密码 请求路径:http://localhost:3022/users/setPassword 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |user_id|用户 id|1|true| |newpassword|新密码|12345670|true| |oldpassworld|旧密码|12|true| **返回结果:** ```json { "code": 200, "message": "修改密码成功" } ``` ## 用户绑定邮箱 请求路径:http://localhost:3022/users/bindEmail 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |user_id|用户 id|1|true| |email|邮箱|zmm@qq.com|true| **返回结果:** ```json { "code": 200, "message": "邮箱修改成功" } ``` ## 退出登陆 请求路径:http://localhost:3022/users/logout 请求方式:POST **返回结果:** ```json { "code": 200, "msg": "退出登录" } ``` ## 关注 请求路径:http://localhost:3022/follow/followPost 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |user_id|用户 id|1|true| |follow_id|关注用户 id|2|true| **返回结果:** ```json { "code": 200, "message": "关注成功" } ``` ## 修改用户默认头像 请求路径:http://localhost:3022/users/editUserImage 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |user_id|用户 id|1|true| |file|from-data||true| **返回结果:** ```json { "code": 200, "message": "修改成功", "url": "http://localhost:3022/uploads/Snipaste_2021-02-22_10-31-43.png" } ``` ## 批量上传 请求路径:http://localhost:3022/users/uploadMoreImg 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |user_id|用户 id|1|true| |file|from-data||true| **返回结果:** ```json { "code": 200, "message": "上传成功", "affectedRows": 2 } ``` ## 批量上传 请求路径:http://localhost:3022/users/publlish 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |user_id|用户 id|1|true| |title|视频标题||true| |url|视频路径||true| |path|||true| |isopen|是否可见(0 可见 1 不可见)|0|true| |posting|封面图||true| **返回结果:** ```json { "code": 200, "msg": "发布成功" } ``` ## 获取文章分类 请求路径:http://localhost:3022/getCate 请求方式:GET 参数:无 **返回结果:** ```json { "list": [ { "id": 1, "category": "javaScript", "status": "1", "create_time": "2021-02-20T10:15:41.000Z" }, { "id": 2, "category": "Vue", "status": "0", "create_time": "2021-02-20T10:16:21.000Z" } ] } ``` ## 根据获取文章分类 id 获取文章标题 请求路径:http://localhost:3022/getPostCate 请求方式:GET |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |id|分类 id|2|true| **返回结果:** ```json { "list": [ { "id": 1, "title": "vue组件开发", "desc": "vue组件开发", "type": null, "treate_time": "2021-02-20T10:18:17.000Z", "cate_id": 2 } ] } ``` ## 添加文章 请求路径:http://localhost:3022/addArticle 请求方式:POST |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |title|文章标题||true| |descs|文章排序||true| |type|分类名称||true| |cate_id|分类 id||true| |content|文章内容||true| **返回结果:** ```json { "code": 200, "msg": "添加成功" } ``` ## 文章编辑 请求路径:http://localhost:3022/editArticle 请求方式:PUT |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |id|文章 id||true| |title|文章标题||true| |descs|文章排序||true| |type|分类名称||true| |cate_id|分类 id||true| |content|文章内容||true| **返回结果:** ```json { "code": 200, "message": "修改成功" } ``` ## 删除文章 请求路径:http://localhost:3022/deleteArticle 请求方式:DELETE |参数名|参数说明|参数示例|是否必传| |-|-|-|-| |id|文章 id||true| **返回结果:** ```json { "code": 200, "message": "删除成功" } ``` ## TODO - 列表分页 - 密码加密 - token 获取