-
Notifications
You must be signed in to change notification settings - Fork 0
REST API
- 获取所有文章:
.get('/article', fetchArticles)
- 通过文章ID获取:
.get('/article/:articleId', fetchArticleById)
// response
{
"action": "GET",
"message": "get article successfully",
"code": "30011",
"success": true,
"item": {
"createdAt": "2018-2-18 15:43 星期日",
"author": "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f",
"isPublished": false,
"articleId": "9876fc80-a189-45b8-b08a-7e34c0e36897",
"archive": "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f",
"title": "Hello B",
"content": "Hello world",
"updatedAt": "2018-2-18 15:53 星期日"
}
}- 某归档类下有多少文章:
.get('/article/archive/:archiveId', fetchArticlesByArchiveId)
- 某作者下有多少文章:
.get('/article/author/:authorId', fetchArticlesByAuthorId)
- 生成一篇新文章:
.post('/article/create', createArticle)
// request
{
title:"Hello Title"
content: "Hello world,new Content"
author: "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f" // authorId required
archive: "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f" // archiveId required
}// response
{
"action": "CREATE",
"message": "article created successfully",
"code": "30041",
"success": true,
"item": {
"articleId": "e19c0375-61ad-4323-bae9-8273fa3b0f68",
"title": "Fuck Title",
"content": "Fuck world",
"author": "authorId",
"archive": "archiveId",
"isPublished": false,
"createdAt": "2018-3-18 12:16 星期日",
"updatedAt": "2018-3-18 12:16 星期日"
}
}- 更新一篇文章(提供完整资源):
.put('/article/update/:articleId', updateArticleById)
// request
{
title:"Hello Title"
content: "Hello world,new Content"
archive: "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f" // archiveId required
}// response
{
"action": "UPDATE",
"message": "article updated successfully",
"code": "30051",
"success": true,
"item": {
"createdAt": "2018-2-18 15:43 星期日",
"author": "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f",
"isPublished": false,
"articleId": "9876fc80-a189-45b8-b08a-7e34c0e36897",
"archive": "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f",
"title": "Hello B",
"content": "Hello world,哈哈fsdhkfjdskf",
"updatedAt": "2018-3-18 18:53 星期日"
}
}- 删除一篇文章:
.del('/article/delete/:articleId', deleteArticleById)
// response
{
"action": "DELETE",
"message": "article deleted successfully",
"code": "30061",
"success": true
}- 发表一篇文章(提供部分资源):
PATCH /rest/article/publish/:articleId
- 撤销一篇文章(提供部分资源):
PATCH /rest/article/unpublish/:articleId
- 获取所有作者:
.get('/author', fetchAuthors)
- 获取某一个作者:
.get('/author/:authorId', fetchAuthorById)
// response
{
"action": "GET",
"message": "get author successfully",
"code": "40011",
"success": true,
"item": {
"createdAt": "2018-3-10 16:37 星期六",
"gender": "F",
"social": null,
"name": "Vickie",
"avatar": null,
"authorId": "77fbee39-d3ee-4580-9ba4-fd96de2571db",
"email": null,
"updatedAt": "2018-3-10 16:37 星期六"
}
}- 更新一个作者:
.put('/author/update/:authorId', updateAuthorById)
// request
{
name: "loveoak"
gender: "F"
email: "example@gmail.com"
social: "somesocialurlarray"
avatar: "avatar_url"
}// response
{
"action": "UPDATE",
"message": "author updated successfully",
"code": "40031",
"success": true,
"item": {
"createdAt": "2018-3-18 19:9 星期日",
"gender": "男",
"social": "somesocialurlarray",
"name": "loveoak",
"avatar": "ddddd",
"authorId": "3f5a150c-d8fd-45e2-a8cd-f0470782b6d4",
"email": "example@gmail.com",
"updatedAt": "2018-3-18 19:16 星期日"
}
}- 生成某个作者的头像:
POST /rest/avatar/create/:authorId
- 更新某个作者的头像:
PUT /rest/avatar/update/:authorId
- 获取所有归档类:
.get('/archive/attach/:attachId', fetchArchivesByAttachId)
// response
{
"action": "QUERY",
"message": "get archive by attachId successfully",
"code": "20021",
"success": true,
"items": []
}- 获取某一个归档:
.get('/archive/:archiveId', fetchArchiveById)
// response
{
"action": "GET",
"message": "get archive successfully",
"code": "20011",
"success": true,
"item": {
"name": "Life Logs",
"archiveId": "9e72abbd-68a4-4537-a794-4eed776c0e",
"updatedAt": "2018-3-1 23:39 星期四"
}
}- 创建一个归档信息:
.post('/archive/create', createArchive)
// request
{
name: "Lifelogs",
attachId: "d5da709f-dc12-413f-a7d6-073357799fb5"
}// response
{
"action": "CREATE",
"message": "archive create successfully",
"code": "20021",
"success": true,
"item": {
"archiveId": "992345e0-6453-4beb-982c-776dfa9e9dbc",
"name": "Lifelogs",
"createdAt": "2018-3-19 0:4 星期一",
"updatedAt": "2018-3-19 0:4 星期一"
}
}- 更新一个归档信息:
.put('/archive/update/:archiveId', updateArchiveById)
// request
{
name: "JS Logs"
}{
"action": "UPDATE",
"message": "archive updated successfully",
"code": "20031",
"success": true,
"item": {
"name": "JS Logs",
"archiveId": "9e72abbd-68a4-4537-a794-4eed776c0e",
"updatedAt": "2018-3-19 0:5 星期一"
}
}- 删除一个归档信息:
.del('/archive/delete/:archiveId', deleteArchiveById)
// response
{
"action": "DELETE",
"message": "archive deleted successfully",
"code": "20041",
"success": true
}- 注册:
.post('/register', userRegister)
// request
{
username: "Vickie"
password: "123456"
}// response
{
"message": "user registered successfuly",
"userInfo": {
"userId": "3ca629ba-f9a1-4255-9948-3a7f345bcf53",
"username": "gongg",
"profile": {
"gender": "F",
"email": "",
"social": "",
"avatar": "",
"createdAt": "2018-4-22 12:49 星期日",
"updatedAt": "2018-4-22 12:49 星期日"
}
},
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiIzY2E2MjliYS1mOWExLTQyNTUtOTk0OC0zYTdmMzQ1YmNmNTMiLCJ1c2VybmFtZSI6ImdvbmdnIiwiaWF0IjoxNTI0MzcyNTgxLCJleHAiOjE1MjQ0NTg5ODF9.dD7w9uwvm5-5OXuRdYi37Grjrx60iQRI8cj0S0caE_4",
"success": true,
"code": "10031"
}- 登录:
.post('/login', userLogin)
// request
{
username: "Vickie"
password: "123456"
}// response
{
"message": "user login successfully",
"success": true,
"code": "10011",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJkNWRhNzA5Zi1kYzEyLTQxM2YtYTdkNi0wNzMzNTc3OTlmYjUiLCJpYXQiOjE1MjQzODAwNzksImV4cCI6MTUyNDQ2NjQ3OX0.gVPQTn_bMUw3xlKrv4uCvgKMICEkvOczmXaiJIsUlAo",
"userId": "d5da709f-dc12-413f-a7d6-073357799fb5",
"username": "vk",
"profile": {
"createdAt": "2018-4-22 14:54 星期日",
"avatar": null,
"gender": "F",
"social": null,
"email": null,
"updatedAt": "2018-4-22 14:54 星期日"
}
}- 登出:
.post('/logout', userLogout)
// request
{
userId: "9fc7f5c1-805f-4dff-94c3-eb6b8a89b36f"
username: "Vickie"
}// response
{
"message": "user logout successfully",
"success": true,
"code": "10021"
}- 获取所属资源
.get('/:archiveType/:userId', fetchAssets)
// response
{
"action": "GET",
"message": "资源获取成功",
"code": "50041",
"success": true,
"item": [
{
"attachKey": "d5da709f-dc12-413f-a7d6-073357799fb5",
"assetKey": "images%2Ffilmtocat.png",
"assetName": "filmtocat.png",
"assetType": "image/png",
"ETag": "\"fdb63695d865608aca0664fe9bc86482\"",
"archiveType": "images",
"url": "https://oakserver.s3.ap-northeast-1.amazonaws.com/images/filmtocat.png",
"assetSize": 98907
},
]
}- 更新资源
.put('/update/:assetkey', updateAssetsByKey)
// request
{
'assetName': 'hhhhhh.png'
'description': '描述'
}// reponse
{
"action": "UPDATE",
"message": "资源更新成功",
"code": "50031",
"success": true,
"item": {
"assetKey": "images%2F42fbfde9-18ca-4d09-a52d-94bcd678465d.png",
"attachKey": "d5da709f-dc12-413f-a7d6-073357799fb5",
"assetName": "hhhhhh.png",
"assetType": "image/png",
"ETag": "\"41b613d52bb109fff52ddb01fb4ee716\"",
"archiveType": "images",
"description": "描述",
"url": "https://oakserver.s3.ap-northeast-1.amazonaws.com/images/42fbfde9-18ca-4d09-a52d-94bcd678465d.png",
"assetSize": 15263
}
}- 删除文件
.del('/delete/:assetkey', deleteAssetsByKey)
// reponse
{
"action": "DELETE",
"message": "资源删除成功",
"code": "50021",
"success": true
}- 上传图片
.post('/upload/image', upload.single('image'), uploadImageAssets)
- 上传文件
.post('/upload/file', upload.single('file'), uploadFileAssets)
- 上传视频文件
.post('/upload/video', upload.single('video'), uploadVdieoAssets)
- 上传音频
.post('/upload/audio', upload.single('audio'), uploadAudioAssets)
- 上传头像
.post('/upload/avatar', upload.single('avatar'), uploadAvatarAssets)
// request
{
"Content-Type": "multipart/form-data"
}
{
"userId": "d5da709f-dc12-413f-a7d6-073357799fb5"
"image": "文件资源" // image、file、audio、video、avatar
}// reponse
{
"action": "UPLOAD",
"message": "资源上传成功",
"code": "50011",
"success": true,
"item": {
"attachKey": "d5da709f-dc12-413f-a7d6-073357799fb5",
"url": "https://oakserver.s3.ap-northeast-1.amazonaws.com/images/42fbfde9-18ca-4d09-a52d-94bcd678465d.png",
"assetKey": "images%2F42fbfde9-18ca-4d09-a52d-94bcd678465d.png",
"assetName": "fall.png",
"assetType": "image/png",
"assetSize": 15263,
"archiveType": "images",
"ETag": "\"41b613d52bb109fff52ddb01fb4ee716\"",
"description": "This is a image"
}
}