auth-rest is a REST API for user authentication. It provides endpoints for user registration, login. The API is built using Node.js, Express.js, and MongoDB.
- Clone the repository:
git clone https://github.com/BornitG/auth-rest.git - Install the dependencies:
pnpm install - Create a
.envfile in the root directory and set the following environment variables:PORT: The port number to run the server on (default: 3000)MONGO_URL: The MongoDB connection URLMONGO_DB_NAME: The name of the MongoDB databaseJWT_SEED: The secret key for JSON Web Tokens
- If you need a database, configure the docker-compose.yml file and run the following command to start the desired services.
docker-compose up -d - Start the server:
pnpm run dev
- Method: POST
- Endpoint:
/api/auth/register - Request Body:
username(string)/(unique): The username of the user.firstName(string): The user's first name.lastName(string): The user's last name.email(string)/(unique): The email of the user.password(string): The password of the user.
- Optional Request:
img(string): The user's profile image
- Response:
user(object): The user is information.token(string): The JSON Web Token for authentication.
- Method: POST
- Endpoint:
/api/auth/login - Request Body:
username(string): The username of the user.email(string): The email of the user.password(string): The password of the user.
- Response:
user(object): The user is information.token(string): The JSON Web Token for authentication.