Skip to content

thuhuong1234/HIT_Project_2023

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Run Locally

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

Running Tests

To run tests, run the following command

  npm run test

Environment Variables

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

Register

  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

VD:

{
    "name":"Nam",
    "password":"Nam111222@",
    "passwordConfirm":"Nam111222@",
    "studentCode":"2020345242",
    "email":"[email protected]",
    "phoneNumber":"0342963649"
}

Kết quả:

{
    "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
    }
}

Login

  POST/api/v1/auth/login 
Parameter Type Description
password string Required. Id of item to fetch
email string Required. Id of item to fetch

VD

{
    "password":"Nam111222@",
    "email":"[email protected]"
}

Kết quả

{
    "status": 200,
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZW1iZXJJZCI6IjY0Y2VkM2VkNTVlMjJjNmU0ZDM0YWEzMyIsImlhdCI6MTY5MTI3NjgzOSwiZXhwIjoxNjkxMzYzMjM5fQ.hZ5QtpI_woQB7zVLruW0j_Rj92NM8RIceuJFx-pDBnw"
}

Kết quả

{
    "status": 200,
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZW1iZXJJZCI6IjY0Y2VkM2VkNTVlMjJjNmU0ZDM0YWEzMyIsImlhdCI6MTY5MTI3NjgzOSwiZXhwIjoxNjkxMzYzMjM5fQ.hZ5QtpI_woQB7zVLruW0j_Rj92NM8RIceuJFx-pDBnw"
}

Forgot-password

POST/api/v1/auth/[email protected]

Forgot-password

{
    "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]>"
    }
}

Reset-password

PUT/api/v1/auth/reset-password
Parameter Type Description
password string Required your new password
token string Required token

Get-me

GET/auth/api/v1/get-me

Refresh-access-token

GET/api/v1/auth/refresh-access-token
{
    "status": 200,
    "newAccessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZW1iZXJJZCI6IjY0Y2VkOWFlODBiOWY1ZjM2N2VjYzQ5ZCIsImlhdCI6MTY5MTI4MzA3OCwiZXhwIjoxNjkxMzY5NDc4fQ.FEzjDl5bOV9p8lWmxz8lzrGeZ8PZGd_D5Xbc9ulbl10"
}

Logout

GET/api/v1/auth/logout
{
    "status": 200,
    "mes": "Logouted!"
}

Get all members

  GET/api/v1/members

Get member

  GET/api/v1/members/${id}
Parameter Type Description
id string Required. Id of item to fetch

Create member

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

Releases

No releases published

Packages

No packages published