Clone the project
git clone [email protected]:thuhuong1234/HIT_Project_2023.git
Go to the project directory
cd server
Install dependencies
npm install
Start the server
npm start
To run tests, run the following command
npm run test
To run this project, you will need to add the following environment variables to your .env file
PORT
= 5000
MONGODB_URI
="mongodb+srv://thuhuong2003:[email protected]/?retryWrites=true&w=majority"
SECRET_KEY
='super-secret'
JWT_EXPIRES_IN
='1d'
JWT_EXPIRES_IN2
= '2d'
URL_SERVER
= http://localhost:5000
USER
= [email protected]
PASS
= hqwnhdxkkqdnqsyi
POST/api/v1/auth/register
Parameter | Type | Description |
---|---|---|
name |
string |
Required. Your name |
email |
string |
Required. Your email |
password |
string |
Required. Your password |
passwordConfirm |
string |
Required. Your passwordConfirm |
studentCode |
string |
Required. Your studentCode |
phoneNumber |
string |
Required. Your phoneNumber |
{
"name":"Nam",
"password":"Nam111222@",
"passwordConfirm":"Nam111222@",
"studentCode":"2020345242",
"email":"[email protected]",
"phoneNumber":"0342963649"
}
{
"status": 201,
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZW1iZXJJZCI6IjY0Y2VkM2VkNTVlMjJjNmU0ZDM0YWEzMyIsImlhdCI6MTY5MTI3NjI3MCwiZXhwIjoxNjkxMzYyNjcwfQ.hkMWo1G_uBjWCCU98l5SwkbnTlPKT6CYnn8ia1vz7nM",
"data": {
"name": "Nam",
"email": "[email protected]",
"phoneNumber": "0342963649",
"role": "member",
"password": "$2b$08$fzaozzjaaHqNYanp7ELkEuLJcDdRYRY3QO/9gyWyn1lt0qMKRg20.",
"studentCode": "2020345242",
"_id": "64ced3ed55e22c6e4d34aa33",
"createdAt": "2023-08-05T22:57:49.893Z",
"updatedAt": "2023-08-05T22:57:49.893Z",
"__v": 0
}
}
POST/api/v1/auth/login
Parameter | Type | Description |
---|---|---|
password |
string |
Required. Id of item to fetch |
email |
string |
Required. Id of item to fetch |
{
"password":"Nam111222@",
"email":"[email protected]"
}
{
"status": 200,
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZW1iZXJJZCI6IjY0Y2VkM2VkNTVlMjJjNmU0ZDM0YWEzMyIsImlhdCI6MTY5MTI3NjgzOSwiZXhwIjoxNjkxMzYzMjM5fQ.hZ5QtpI_woQB7zVLruW0j_Rj92NM8RIceuJFx-pDBnw"
}
{
"status": 200,
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZW1iZXJJZCI6IjY0Y2VkM2VkNTVlMjJjNmU0ZDM0YWEzMyIsImlhdCI6MTY5MTI3NjgzOSwiZXhwIjoxNjkxMzYzMjM5fQ.hZ5QtpI_woQB7zVLruW0j_Rj92NM8RIceuJFx-pDBnw"
}
POST/api/v1/auth/[email protected]
{
"status": 200,
"message": "success",
"reset": {
"accepted": [
"[email protected]"
],
"rejected": [],
"ehlo": [
"SIZE 35882577",
"8BITMIME",
"AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH",
"ENHANCEDSTATUSCODES",
"PIPELINING",
"CHUNKING",
"SMTPUTF8"
],
"envelopeTime": 774,
"messageTime": 705,
"messageSize": 811,
"response": "250 2.0.0 OK 1691281192 b2-20020aa78702000000b0066ccb8e8024sm3641815pfo.30 - gsmtp",
"envelope": {
"from": "[email protected]",
"to": [
"[email protected]"
]
},
"messageId": "<[email protected]>"
}
}
PUT/api/v1/auth/reset-password
Parameter | Type | Description |
---|---|---|
password |
string |
Required your new password |
token |
string |
Required token |
GET/auth/api/v1/get-me
GET/api/v1/auth/refresh-access-token
{
"status": 200,
"newAccessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZW1iZXJJZCI6IjY0Y2VkOWFlODBiOWY1ZjM2N2VjYzQ5ZCIsImlhdCI6MTY5MTI4MzA3OCwiZXhwIjoxNjkxMzY5NDc4fQ.FEzjDl5bOV9p8lWmxz8lzrGeZ8PZGd_D5Xbc9ulbl10"
}
GET/api/v1/auth/logout
{
"status": 200,
"mes": "Logouted!"
}
GET/api/v1/members
GET/api/v1/members/${id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of item to fetch |
Parameter | Type | Description |
---|---|---|
name |
string |
Required.Member's name |
password |
string |
Required.Member's password |
passwordConfirm |
string |
Required.Member's passwordConfirm |
email |
string |
Required.Member's email |
role |
string |
Required.Member's role |
{
"name": "Hong",
"password": "Ha001234@",
"passwordConfirm": "Ha001234@",
"studentCode": "202034510",
"email": "[email protected]",
"role": "leader"
}
PUT/api/v1/members/${id}
Parameter | Type | Description |
---|---|---|
name |
string |
Member's name |
password |
string |
Member's password |
email |
string |
Member's email |
role |
string |
Member's role |
image |
string |
Member's image by body or upload file |
DELETE/api/v1/members/${id}
GET/api/v1/excel