- 下载 mongodb
- 安装方式
- 安装好以后在终端中执行
mongod
命令启动 mongodb 数据库
不明白的也可以参考这篇安装配置教程:http://www.runoob.com/mongodb/mongodb-window-install.html
在终端中进入接口项目目录并执行以下命令
npm install
npm run dev
注意:
- 启动服务之前务必保证先启动 mongodb 数据库
接口服务默认占用 8000 端口,如果 8000 端口被占用,解决方式如下:
方式一:关闭其他占用 8000 端口的服务
方式二:修改项目中的 package.json
文件中的端口号配置(见下图)
http://localhost:8000/api/v1/
POST
/users
BODY
{
"username": "xxx",
"password": "xxx",
"nickname": "xxx"
}
GET
/users/:userId
GET
/users?username=xxx
GET
/users?nickname=xxx
GET
/users/url_token/:xxx
PATCH
/users/:userId/url_token
BODY
{
"urlToken": "xxx"
}
PATCH
/users/:userId/avatar
BODY
{
"file": "xxx",
"x": "xxx",
"y": "xxx",
"width": "xxx",
"height": "xxx"
}
POST
/users/signup
BODY
{
"email": "xxx",
"password": "xxx",
"nickname": "xxx"
}
POST
/users/signin
BODY
{
"email": "xxx",
"password": "xxx"
}
PATCH
/users/:userId/profile
BODY
{
"name": "xxx",
"birthday": "xxx",
"cellphone": "xxx",
"location": "xxx",
"skills": "xxx",
"gender": "xxx",
"website": "xxx",
"bio": "xxx"
}
PATCH
/users/:userId/password
BODY
{
"password": "xxx",
"newPassword": "xxx"
}
DELETE
/users/:userId
POST
/posts
BODY
{
"title": "xxx",
"body": "xxx",
"tags": "xxx",
"userId": "xxx"
}
GET
/posts/:postId
GET
/posts注:默认获取最新发布的问题
PARAMS
_page
页码_limit
每页大小filter
筛选条件- hot 热门
- unresponsive 等待回复
tags
标签
GET
/posts?userId=xxx
GET
/users/:userId/comments/questions
PATCH
/posts/:postId
BODY
{
"title": "xxx",
"body": "xxx",
"tags": "xxx"
}
DELETE
/posts/:postId
POST
/comments
BODY
{
"body": "xxx",
"userId": "xxx",
"postId": "xxx"
}
GET
/comments/count?postId=xxx
GET
/comments?postId=xxx
DELETE
/comments/:commentId
PATCH
/comments/:commentId
BODY
{
"body": ""
}
GET
/tags
PARAMS
_page
页码_limit
每页大小
GET
/tags/followers/:userId
GET
/tags/:tagName
POST
/tags/:tagName/followers
BODY
{
"userId": "xxx"
}
GET
/votes
PARAMS
- type
- 所属类型
- typeId
- 类型id
- userId
- 用户id
POST
/votes
BODY
{
"type": "xxx",
"typeId": "xxx",
"value": "xxx",
"userId": "xxx"
}
注:
- type 值为
posts
或者comments
- typeId 为 type 类型的 id
- value 可取的值为
0
、1
、-1
POST
/works
BODY
{
"user": "xxx",
"company": "xxx",
"position": "xxx",
"startDate": "xxx",
"endDate": "xxx",
"city": "xxx",
"skills": "xxx",
"description": "xxx"
}
GET
/users/:userId/works
PATCH
/works/:wordId
BODY
{
"company": "xxx",
"position": "xxx",
"startDate": "xxx",
"endDate": "xxx",
"city": "xxx",
"skills": "xxx",
"description": "xxx"
}
DELETE
/works/:workId
POST
/upload