A brief description of what this project does and who it's for
challenge:
- Challenge A : CRUD
- Challenge B : Websocket (without Kafka, reason: my machine does not have kafka, installing and set it up takes time. I can do it anyway)
resulting RFC7807
format as follows
all error resulting 400
, created resulting 201
all success resulting 200
use Thunder Client on vsCode to test the API
endpoint testpoint included on thunder
folder
Menus:
POST /utility/file-upload
Header:
Content-Type | multipart/form-data |
Authorization | Bearer token |
Body:
file | open file |
Response:
Content-Type: application/json
{
"statusCode": 200,
"message": null,
"data": {
"originalname": "Screenshot 2023-04-09 at 04.26.30.png",
"filename": "8d540d50-43ab-4f85-a900-ae6ac33ed3cb.png"
}
}
POST /users/register
Content-Type: application/json
{
"name":"zonblade",
"username":"hehe",
"password":"testing",
"email":"testing@test.te"
}
Response:
HTTP_HEADER: 201 (Created)
Content-Type: application/json
{
"statusCode": 201,
"message": null,
"data": {
"token": "token here"
}
}
GET /users/login
Content-Type: application/json
{
"username": "string",
"password": "string"
}
Response:
HTTP_HEADER: 200 (OK)
Content-Type: application/json
{
"statusCode": 200,
"message": null,
"data": {
"token": "token here"
}
}
PATCH /users
Authorization: Bearer token
Content-Type: application/json
{
"name": "string", // optional
"username": "string", // optional
"email": "string", // optional
"image": [ // optional
"string",
"string"
]
}
Response:
HTTP_HEADER: 200 (OK)
Content-Type: application/json
{
"statusCode": 200,
"message": null,
"data": null
}
GET /users?search=type something
Authorization: Bearer token
Response:
HTTP_HEADER: 200 (OK)
Content-Type: application/json
{
"statusCode": 200,
"message": null,
"data": [
{
"id": "6432fcc07f16ab38269fa91b",
"name": "zonblade",
"username": "string",
"image": [],
"prefrences": {
"horoscope": null,
"zodiac": null,
"height": 0,
"weight": 0,
"interest": [],
"about": null
}
}
]
}
GET /users/${id}
Authorization: Bearer token
Response:
HTTP_HEADER: 200 (OK)
Content-Type: application/json
{
"statusCode": 200,
"message": null,
"data": {
"id": "6432fcc07f16ab38269fa91b",
"name": "zonblade",
"username": "string",
"image": [],
"prefrences": {
"horoscope": null,
"zodiac": null,
"height": 0,
"weight": 0,
"interest": [],
"about": null
}
}
}
GET /chats
Authorization: Bearer token
Response:
HTTP_HEADER: 200 (OK)
Content-Type: application/json
{
"statusCode": 200,
"message": null,
"data": [
{
"id": "64333e0dc57ff31598bae585",
"username": "string2",
"name": "string2",
"image": [],
"last_message": ""
}
]
}
GET /chats/${id}
Authorization: Bearer token
Response:
HTTP_HEADER: 200 (OK)
Content-Type: application/json
{
"statusCode": 200,
"message": null,
"data": [
{
"id": "6433483d125981d7bd5170b1",
"message": "hy",
"date": "2023-04-09T23:20:29.000Z",
"itsMe": true
}
]
}
ENDPOINT http://ip_or_domain:port?target=${target}&jwt=${token}
param | desc |
---|---|
target | user_id of user you'd want to chat. |
jwt | your token without Bearer |
EVENT: message
{
"message":"hello",
"image":"some.png"
}
Response:
EVENT: message
{
"user_id":"string id", // to determine which one is which
"message":"hello",
"image":"some.png"
}
used to determine this room has user typing.
EVENT: message.typing