$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
POST/api/v1/auth/register
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your name |
email |
string |
Required. Your email |
password |
string |
Required. Your password |
{
"username":"Hoang Ha 2",
"email":"[email protected]",
"password":"Nam12345@"
}
{
"newUser": {
"id": 5,
"username": "Hoang Ha 2",
"password": "$2b$10$WzoB2Qu3qKNNPpRGUQLuWefKhOTe7wnnNjI5WYsTzhzfS2cRkQrn2",
"email": "[email protected]",
"role": "User",
"phone": null,
"avatar": null,
"createAt": "2024-06-20T05:41:53.825Z",
"updateAt": "2024-06-20T05:41:53.825Z"
},
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjUsImlhdCI6MTcxODg2MjExMywiZXhwIjoxNzE5NDY2OTEzfQ.5uul9t6sFSoZBZxQALmT81I_UzAXWthAMpC3YQ2oUfM"
}
{
"message": "User already exists!",
"error": "Bad Request",
"statusCode": 400
}
{
"message": [
"password must match /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$/ regular expression"
],
"error": "Bad Request",
"statusCode": 400
}
{
"message": [
"email must be an email",
"email should not be empty"
],
"error": "Bad Request",
"statusCode": 400
}
POST/api/v1/auth/login
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your name |
email |
string |
Required. Your email |
password |
string |
Required. Your password |
{
"username":"Thu Hang",
"email":"[email protected]",
"password":"Hang1234@"
}
{
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTcxODg2MTg2NCwiZXhwIjoxNzE5NDY2NjY0fQ.0u8MFeTMqvKYZ1VuJ7AqyhHPPRPTUtM9Cn7f4awAIwQ"
}
{
"message": "User not found",
"error": "Not Found",
"statusCode": 404
}
{
"statusCode": 500,
"message": "Internal server error"
}
GET/api/v1/auth/profile
Headers.Authorization
: Bearer
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjEsImlhdCI6MTcxODg2MTg2NCwiZXhwIjoxNzE5NDY2NjY0fQ.0u8MFeTMqvKYZ1VuJ7AqyhHPPRPTUtM9Cn7f4awAIwQ
{
"id": 1,
"username": "Thu Hang",
"password": "$2b$10$pPzx6./9Ez3PzdzbqaMmT.mUvmC3xhCyNj6a3R9Fc4BLVo1KkOqSe",
"email": "[email protected]",
"role": "Leader",
"phone": null,
"avatar": null,
"createAt": "2024-02-28T17:58:46.710Z",
"updateAt": "2024-02-28T17:59:40.224Z"
}
{
"message": "Unauthorized",
"statusCode": 401
}
POST/api/v1/users
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Your name |
email |
string |
Required. Your email |
password |
string |
Required. Your password |
{
"username":"Phuong Ngan Nguyen",
"email":"[email protected]",
"password":"Pngan1234@"
}
{
"id": 6,
"username": "Phuong Ngan Nguyen",
"password": "$2b$10$Jtlvxf0ZfT4n0tdkpclUk.RcUcWaxeenwStevLgLdiXfUy0IlZ/FC",
"email": "[email protected]",
"role": "User",
"phone": null,
"avatar": null,
"createAt": "2024-06-20T06:03:17.183Z",
"updateAt": "2024-06-20T06:03:17.183Z"
}
{
"message": "User already exists!",
"error": "Bad Request",
"statusCode": 400
}
{
"message": "Unauthorized",
"statusCode": 401
}
{
"message": [
"email must be an email",
"email should not be empty",
"password must match /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$/ regular expression",
"password must be a string",
"password should not be empty"
],
"error": "Bad Request",
"statusCode": 400
}
GET/api/v1/users/{id}
GET/api/v1/users/1
"id": 1,
"username": "Thu Hang",
"password": "$2b$10$pPzx6./9Ez3PzdzbqaMmT.mUvmC3xhCyNj6a3R9Fc4BLVo1KkOqSe",
"email": "[email protected]",
"role": "Leader",
"phone": null,
"avatar": null,
"createAt": "2024-02-28T17:58:46.710Z",
"updateAt": "2024-02-28T17:59:40.224Z"
}
{
"message": "User not found!",
"error": "Not Found",
"statusCode": 404
}
POST/api/v1/users?page= &limit=
GET/api/v1/users?page=1&limit=10
{
"users": [
{
"id": 1,
"username": "Thu Hang",
"password": "$2b$10$pPzx6./9Ez3PzdzbqaMmT.mUvmC3xhCyNj6a3R9Fc4BLVo1KkOqSe",
"email": "[email protected]",
"role": "Leader",
"phone": null,
"avatar": null,
"createAt": "2024-02-28T17:58:46.710Z",
"updateAt": "2024-02-28T17:59:40.224Z"
},
{
"id": 2,
"username": "Hoang Nam",
"password": "$2b$10$pCGFc71BmoCvl8WWpdsqQe55hEzY09mbcuF8OoqaUuVCyFod.r3O6",
"email": "[email protected]",
"role": "User",
"phone": null,
"avatar": null,
"createAt": "2024-03-21T08:22:14.345Z",
"updateAt": "2024-03-21T08:22:14.345Z"
},
{
"id": 3,
"username": "Phuong Ngan",
"password": "$2b$10$.1O/c4hblwfx7etddR1YDuwdacICfUTpcxy.dKuGnUXZGvmysXeU6",
"email": "[email protected]",
"role": "User",
"phone": null,
"avatar": null,
"createAt": "2024-03-21T08:23:03.546Z",
"updateAt": "2024-03-21T08:23:03.546Z"
},
],
"total": 6,
"page": "1",
"pages": 1,
"limit": 10
}
{
"statusCode": 500,
"message": "Internal server error"
}
{
"message": "Unauthorized",
"statusCode": 401
}
PATCH/api/v1/users/{id}
{
"role":"Leader"
}
{
"id": 1,
"username": "Thu Hang",
"password": "$2b$10$pPzx6./9Ez3PzdzbqaMmT.mUvmC3xhCyNj6a3R9Fc4BLVo1KkOqSe",
"email": "[email protected]",
"role": "Leader",
"phone": null,
"avatar": null,
"createAt": "2024-02-28T17:58:46.710Z",
"updateAt": "2024-06-20T06:21:07.649Z"
}
{
"statusCode": 500,
"message": "Internal server error"
}
{
"message": "Unauthorized",
"statusCode": 401
}
{
"message": "User not found!",
"error": "Not Found",
"statusCode": 404
}
{
"message": [
"email must be an email",
"password must match /^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,}$/ regular expression"
],
"error": "Bad Request",
"statusCode": 400
}
DELETE/api/v1/users/{id}
DELETE/api/v1/users/3
{
"id": 3,
"username": "Phuong Ngan",
"password": "$2b$10$.1O/c4hblwfx7etddR1YDuwdacICfUTpcxy.dKuGnUXZGvmysXeU6",
"email": "[email protected]",
"role": "User",
"phone": null,
"avatar": null,
"createAt": "2024-03-21T08:23:03.546Z",
"updateAt": "2024-03-21T08:23:03.546Z"
}
{
"statusCode": 500,
"message": "Internal server error"
}
{
"message": "Unauthorized",
"statusCode": 401
}
{
"message": "User not found!",
"error": "Not Found",
"statusCode": 404
}