owned this note
owned this note
Published
Linked with GitHub
# Student Routes:
### /signin
- Method: POST
- Protected: true
- Request Body:
```javascript
{
"email" : String,
"password" : String
}
```
- Response:
- Success response:
- Status code: 200
- Response JSON:
```json
{
"error": false,
"message": "Logged In Successfully",
"data": [
{
"id": int,
"email": String,
"username": String,
"roleId": String,
"cohortId": String,
"avatar": String
}
]
}
```
- Errors response:
- Status code:
- Wrong email or password: 406
- Validation error: 400
- Server error: 500
- Response JSON:
```json
{
"error": true,
"message": "error message",
"data": null
}
```
### /profile/:id
- Method: GET
- Protected: true
- Response:
- Success response:
- Status code: 200
- Response JSON:
```json
{
"error": boolean,
"message": "Profile Successfully",
"data": [
{
"id": int,
"email": String,
"username": String,
"roleId": String,
"cohortId": String,
"avatar": String
}
]
}
```
- Errors response:
- Status code:
- Unauthorized: 401
- Server error: 500
- Response JSON:
```json
{
"error": true,
"message": "error message",
"data": null
}
```
### /posts/:id
- Method: GET
- Protected: true
- Response:
- Success response:
- Status code: 200
- Response JSON:
```json
{
"error": false,
"message": "Success",
"data": [
{
"post_id":int,
"post_content":string,
"user_id":int
}
]
}
```
- Errors response:
- Status code:
- Unauthorized: 401
- Not found: 404
- Server error: 500
- Response JSON:
```json
{
"error": true,
"message": "error message",
"data": null
}
```
### /comments/:id
- Method: GET
- Protected: true
- Response:
- Success response:
- Status code: 200
- Response JSON:
```json
{
"error": false,
"message": "Profile Successfully",
"data": [
{
"user_id":int,
"comment_id":int,
"post_id":int,
"comment_content":string,
"cohort_id":int
}
]
}
```
- Errors response:
- Status code:
- Not found: 404
- Server error: 500
- Response JSON:
```json
{
"error": true,
"message": "error message",
"data": null
}
```
### /cohorts
- Method: GET
- Protected: true
- Response:
- Success response:
- Status code: 200
- Response JSON:
```json
{
"error": false,
"message": "Profile Successfully",
"data": [
{
"name": String,
"thumbnail": file,
"created_at": date,
"start_at": date,
"end_at": date
}
]
}
```
- Errors response:
- Status code:
- Unauthorized: 401
- Server error: 500
- Response JSON:
```json
{
"error": true,
"message": "error message",
"data": null
}
```
### /users/:cohortid
- Method: GET
- Protected: true
- Response:
- Success response:
- Status code: 200
- Response JSON:
```json
{
"error": false,
"message": "Profile Successfully",
"data": [
{
"name": String,
"thumbnail": file,
"created_at": date,
"start_at": date,
"end_at": date
}
]
}
```
- Errors response:
- Status code:
- Not found: 404
- Server error: 500
- Response JSON:
```json
{
"error": true,
"message": "error message",
"data": null
}
```
### /users/:user_id
- Method: GET
- Protected: true
- Response:
- Success response:
- Status code: 200
- Response JSON:
```json
{
"error": false,
"message": "Profile Successfully",
"data": [
{
"name": String,
"thumbnail": file,
"created_at": date,
"start_at": date,
"end_at": date
}
]
}
```
- Errors response:
- Status code:
- Unauthorized: 401
- Server error: 500
- Response JSON:
```json
{
"error": true,
"message": "error message",
"data": null
}
```