| Route | HTTP | Header(s) | Body | Description |
|---|---|---|---|---|
| user/register | POST | none | email: String password: String |
Create a user (role auto user) success: (201), example: {"_id": String, "name": String, "email": String, "password": String,, "watchTags": [String, String, etc]} errors: (500), error |
| user/login | POST | none | email: String password: String |
Login and get token based on credentials success: (200), example: {"_id": String, "name": String, "email": String, "password": String, "token": String} errors: (400), {message: 'Invalid email/password'} (500), error |
| /user/getdata | GET | Authenticated: (token), |
none | Get users info success: (200), example: [{"_id": String, "name": String, "email": String, "password": String, "watchTags": [String, String, etc]}br />errors: (500), error |
| /user/watchedtag | Post | (token),(check isUser) |
tag: String | Update a user watchtag with new tag success: (200), example: {message: 'Updated'} errors: (404), example: {message: 'tag sudah ada'} (500), error |
| Route | HTTP | Header(s) | Body | Description |
|---|---|---|---|---|
| /question | GET | Authenticated: (token) |
none | Get all questions success: (200), example: [{"title": String, "description": String, "answer": [Object, Object, etc], "votes": [Object, Object, etc], "tags": [String, String, etc], userId: Object}, {"title": String, "description": String, "answer": [Object, Object, etc], "votes": [Object, Object, etc], "tags": [String, String, etc], userId: Object}, etc] errors: (500), error |
| /question/:questionId | GET | Authenticated: (token) |
none | Get a single question info success: (200), example: {"title": String, "description": String, "answer": [Object, Object, etc], "votes": [Object, Object, etc], "tags": [String, String, etc], userId: Object} errors: (404), example: {message: 'Product not found'} (500), error |
| /question/ | POST | Authenticated: (token), Authorized: (check isUser) |
title: String description: String tags: [String, String] |
Create a question success: (201), example: {"title": String, "description": String, "answer": [Object, Object, etc], "votes": [Object, Object, etc], "tags": [String, String, etc], userId: Object} errors: (400), example: {"message": String} (500), error |
| /question/:id/:questionId | PUT | Authenticated: (token) Authorized: (check isUser) |
title: String description: String tags: [String, String] |
Update a question with new info success: (200), example: {"title": String, "description": String, "answer": [Object, Object, etc], "votes": [Object, Object, etc], "tags": [String, String, etc], userId: Object} errors: (404), example: {message: 'Question not found'} (500), error |
| /question/downvotes/:questionId | PATCH | Authenticated: (token), Authorized: (check isUser) |
status: String | Update votes of question success: (200), example: {"title": String, "description": String, "answer": [Object, Object, etc], "votes": [Object, Object, etc], "tags": [String, String, etc], userId: Object} errors: (404), example: {message: 'Question not found'} (500), error |
| /question/:id/:questionId | DELETE | Authenticated: (token), Authorized: (check isUser) |
none | Delete a question success: (200), example: {message: 'Question successfully deleted'} errors: (404), example: {message: 'Question not found'} (500), error |
| Route | HTTP | Header(s) | Body | Description |
|---|---|---|---|---|
| /answers/:questionId | GET | Authenticated: (token) |
none | Get answer by questionId success: (200), example: {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object}, {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object} errors: (500), error |
| /answers/:id/:questionId | POST | Authenticated: (token), Authorized: (check isUser) |
title: String description: String questionId: String |
Create a answer success: (201), example: {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object}, {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object} errors: (400), example: {"message": String} (500), error |
| /answers/:id/:answerId | PUT | Authenticated: (token) Authorized: (check isUser) |
title: String description: String |
Update a answer with new info success: (200), example: {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object}, {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object} errors: (404), example: {message: 'Answer not found'} (500), error |
| /answers/:id/votes/:answerId | PATCH | Authenticated: (token), Authorized: (check isUser) |
status: String | Update votes of answer success: (200), example: {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object}, {"title": String, "description": String, "votes": [Object, Object, etc], "questionId": Object, userId: Object} errors: (404), example: {message: 'Answer not found'} (500), error |
| /answers/:id/:answerId | DELETE | Authenticated: (token), Authorized: (check isUser) |
none | Delete a answer success: (200), example: {message: 'Answer successfully deleted'} errors: (404), example: {message: 'Answer not found'} (500), error |
| Route | HTTP | Header(s) | Body | Description |
|---|---|---|---|---|
| /tags | GET | Authenticated: (token) |
none | Get all tags success: (200), example: [{"name": String}, {"name": String}, etc] errors: (500), error |
Server:
server-stuckoncode.mri.web.id
Client: stuckoncode.mri.web.id