This is a restful api for chatting-app.
npm install
docker-compose up -d
- GET /api/user/getUsers
- GET /api/user/getOnlineUsers
- POST /api/user/register
- POST /api/user/addFriend/:id
- GET /api/user/getFriends/:id
- PUT /api/user/deleteFriend/:id
- POST /api/user/login
- POST /api/user/refreshToken
- POST /api/user/logout
- POST /api/message/addMessage
- GET /api/message/findMessage/:conversation
- GET /api/message/searchMessage/:text
- POST /api/chat/addChat
GET /api/user/getUsers
curl --location --request GET 'localhost:5000/api/user/getUsers' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM'
[
{
"_id": "61ade606df1e44d8e945f4ed",
"username": "testuser",
"password": "$2b$10$ldaY2e275KCiR1q4QDie2uEv70EZRZpc98f8txb7m1vgKq3/qImnS",
"email": "testuser@gmail.com",
"__v": 0,
"friendlist": []
},
{
"_id": "61d57f0ad177bbe31f670b13",
"username": "testuser2",
"password": "$2b$10$SLQqdIBU6eAJVKjChLdeHOEutinFA3f6k3KBo8l/NOg4ZttDxgRJq",
"email": "testuser2@gmail.com",
"__v": 0,
"friendlist": []
}
]
GET /api/user/getOnlineUsers
curl --location --request GET 'localhost:5000/api/user/getOnlineUsers' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM'
{
"_id": "62444229da59d3de54257d7a",
"username": "test",
"password": "$2b$10$bXSCt8R1S91K3sKslCm33OAhOKovMGEA0PNR0ZKzRvAHrLyBqyAp6",
"email": "test@gmail.com",
"friendlist": [],
"__v": 0,
"online": true
}
POST /api/user/register
curl --location --request POST 'localhost:5000/api/user/register' \--header 'Content-Type: application/json' \--data-raw '{"username":"test","password":"test", "email": "test@gmail.com"}'
{
"username": "test",
"password": "$2b$10$bXSCt8R1S91K3sKslCm33OAhOKovMGEA0PNR0ZKzRvAHrLyBqyAp6",
"email": "test@gmail.com",
"friendlist": [],
"_id": "62444229da59d3de54257d7a",
"__v": 0
}
POST /api/user/addFriend/:id
curl --location --request POST 'localhost:5000/api/user/addfriend/61ade606df1e44d8e945f4ed' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM' \
--header 'Content-Type: application/json' \
--data-raw '{ "userid": "62444229da59d3de54257d7a" }'
[
"61ade606df1e44d8e945f4ed"
]
GET /api/user/getFriends/:id
curl --location --request GET 'localhost:5000/api/user/getfriends/61ade606df1e44d8e945f4ed' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM'
[
"62444229da59d3de54257d7a"
]
PUT /api/user/deleteFriend/:id
curl --location --request DELETE 'localhost:5000/api/user/deleteFriend/61ade606df1e44d8e945f4ed' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM' \
--header 'Content-Type: application/json' \
--data-raw '{ "userid": "62444229da59d3de54257d7a" }'
[]
POST /api/user/login
curl --location --request POST 'localhost:5000/api/user/login' \--header 'Content-Type: application/json' \--data-raw '{"email": "test@gmail.com","password": "test"}'
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoidGVzdEBnbWFpbC5jb20iLCJpYXQiOjE2NjAxNTQyOTMsImV4cCI6MTY2MDE1NjA5M30.bXXZkzAx6jjB8lyjIX1XF1VQM0Hxq03hKQBG0E_2W6Y",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoidGVzdEBnbWFpbC5jb20iLCJpYXQiOjE2NjAxNTQyOTMsImV4cCI6MTY2MDE1Nzg5M30.9KGtuCxIaA7nAoVZ4yyBjp_4zsyZYLxtOxFPN6niE8g"
}
POST /api/user/refreshToken
curl --location --request POST 'localhost:5000/api/user/refreshToken' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoidGVzdEBnbWFpbC5jb20iLCJpYXQiOjE2NjAxNTQyOTMsImV4cCI6MTY2MDE1Nzg5M30.9KGtuCxIaA7nAoVZ4yyBjp_4zsyZYLxtOxFPN6niE8g'
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoidGVzdEBnbWFpbC5jb20iLCJpYXQiOjE2NjAxNTQzOTgsImV4cCI6MTY2MDE1NjE5OH0.2Y5_7HL2lji-UhXqkm3sO-IvvLpJCmAFOAoCbcuo5aU",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyIjoidGVzdEBnbWFpbC5jb20iLCJpYXQiOjE2NjAxNTQzOTgsImV4cCI6MTY2MDE1Nzk5OH0.bIgA7wUcC-eYet5ozRkQuuSO0YH1ES4M7SfrRWgS6wM"
}
POST /api/user/logout
curl --location --request POST 'localhost:5000/api/user/logout' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM' \
--header 'Content-Type: application/json' \
--data-raw '{ "email": "test@gmail.com" }'
{
"_id": "62444229da59d3de54257d7a",
"username": "test",
"password": "$2b$10$bXSCt8R1S91K3sKslCm33OAhOKovMGEA0PNR0ZKzRvAHrLyBqyAp6",
"email": "test@gmail.com",
"friendlist": [],
"__v": 0,
"online": false
}
POST /api/message/addMessage
curl --location --request POST 'localhost:5000/api/message/addMessage' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM' \
--header 'Content-Type: application/json' \
--data-raw '{ "sender": "62444229da59d3de54257d7a", "conversation": "6244561aef7e1b875bada74f", "text": "test message" }'
{
"sender": "62444229da59d3de54257d7a",
"conversation": "6244561aef7e1b875bada74f",
"text": "test message",
"_id": "62c2ea648f2fec3558e34db8",
"createdAt": "2022-07-04T13:25:56.418Z",
"updatedAt": "2022-07-04T13:25:56.418Z",
"__v": 0
}
GET /api/message/findMessage/:conversation
curl --location --request GET 'localhost:5000/api/message/findMessage/6244561aef7e1b875bada74f' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM'
[
{
"_id": "62c2ea648f2fec3558e34db8",
"sender": "62444229da59d3de54257d7a",
"conversation": "6244561aef7e1b875bada74f",
"text": "test message",
"createdAt": "2022-07-04T13:25:56.418Z",
"updatedAt": "2022-07-04T13:25:56.418Z",
"__v": 0
}
]
GET /api/message/searchMessage/:text
curl --location --request GET 'localhost:5000/api/message/searchMessage/test message' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM'
[
{
"_id": "62c2ea648f2fec3558e34db8",
"sender": "62444229da59d3de54257d7a",
"conversation": "6244561aef7e1b875bada74f",
"text": "test message",
"createdAt": "2022-07-04T13:25:56.418Z",
"updatedAt": "2022-07-04T13:25:56.418Z",
"__v": 0
}
]
POST /api/chat/addChat
curl --location --request POST 'localhost:5000/api/chat/addChat' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.dGVzdEBnbWFpbC5jb20.ndABZG7XtdL0FAA-HFGc5RatvoPzRHJ2FwPntu9GffM' \
--header 'Content-Type: application/json' \
--data-raw '{ "user1": "62444229da59d3de54257d7a","user2": "6244410b8a754cd6da293afc" }'
{
"users": [
"62444229da59d3de54257d7a",
"6244410b8a754cd6da293afc"
],
"_id": "6244561aef7e1b875bada74f",
"__v": 0
}