-
Clone the repository to your local machine:
git clone https://github.com/omkar231098/pioneer_assessment.git
-
Install the dependencies:
npm install
-
Set up environment variables by creating a
.env
file and adding the following:SECRET_KEY=your_secret_key_here DATABASE_URL=your_mongodb_URL PORT=8500
-
Start the server:
npm run server
The server should now be running on http://localhost:8500.
- URL:
/auth/register
- Method:
POST
- Description: Register a new user.
- Request Body:
{ "username": "johndoe", "password": "password123" }
- Success Response:
{ "success": true, "message": "Registration successful! You can now log in." }
- Error Response:
{ "success": false, "message": "User already exists. Please use a different username." }
- URL:
/auth/login
- Method:
POST
- Description: Log in with username and password.
- Request Body:
{ "username": "johndoe", "password": "password123" }
- Success Response:
{ "status": true, "message": "Successfully logged in", "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }
- Error Response:
{ "status": false, "message": "Incorrect Password" }
- URL:
/auth/logout
- Method:
POST
- Description: Log out the user and blacklist the token.
- Success Response:
Logged out successfully
- Error Response:
Server error
- URL:
/gethello
- Method:
GET
- Description: Sample route to return a hello message.
- Request Headers:
Authorization: your_access_token_here
- Success Response:
{ "message": "Hello, World!" }
- Error Response:
{ "error": "Internal Server Error" }
Swagger documentation for the API endpoints is available at http://localhost:8500/documentations when the server is running. You can use Swagger UI or a similar tool to interactively explore and test the API.
Deployed Swagger Documentation https://pioneer-assessment.onrender.com/documentations
This project is licensed under the MIT License - see the LICENSE file for details.