Welcome to the documentation for the Innovation Assignment API. This guide will help you understand the available endpoints, their purposes, and the expected request and response formats.
This API is designed to provide functionality for user management, authentication, and profile manipulation. It includes features such as user registration, login, profile updates, admin creation, and more.
Follow these steps to get the project up and running.
- Node.js, libraries.
- Mongo DB
git clone https://github.com/Pranav915/InnovationAssignment.git
Create .env file and populate with the envrionment variables.
# Innovation Assignment Configuration (Example .env file)
# Port for the API server
API_PORT=5000
# MongoDB URI for database connection
MONGO_URI=your_mongo_uri
# Localhost URL for the client application
LOCALHOST=http://localhost:3000/
# Authentication Token for secure communication
AUTH_TOKEN=
npm install
npm start
You must see the server live on localhost:5000.
- Endpoint:
POST /register
- Purpose: Register a new user.
- Request Body:
type
: formdataform
:name
: User's nameemail
: User's emailphoneNumber
: User's phone numberpassword
: User's password
files
:name
: imagevalue
: Path to the image file
- Headers:
Content-Type
: multipart/form-data
- Response:
- 201 Created: User registered successfully
- 400 Bad Request: Invalid request format or missing required fields
- 409 Conflict: User with the same email or phone number already exists
- Endpoint:
POST /createAdmin
- Purpose: Create a new admin account.
- Request Body:
type
: formdataform
:name
: Admin's nameemail
: Admin's emailphoneNumber
: Admin's phone numberpassword
: Admin's password
files
:name
: imagevalue
: Path to the image file
- Headers:
Content-Type
: multipart/form-dataAuthorization
: Bearer token for authentication
- Response:
- 201 Created: Admin account created successfully
- 400 Bad Request: Invalid request format or missing required fields
- 401 Unauthorized: Invalid or missing authentication token
- 403 Forbidden: User lacks permission to create an admin account
- Endpoint:
POST /login
- Purpose: Authenticate a user.
- Request Body:
{ "identifier":"7066834146", "password": "12345" }
- Response:
- 200 OK: Authentication successful, returns JWT token
- 401 Unauthorized: Invalid credentials
- Endpoint:
POST /deleteUser/:userId
- Purpose: Delete a user account.
- Headers:
Authorization
: Bearer token for authentication
- Response:
- 200 OK: User deleted successfully
- 401 Unauthorized: Invalid or missing authentication token
- 403 Forbidden: User lacks permission to delete the account
- 404 Not Found: User with specified userId not found
- Endpoint:
POST /updateProfileImage/:userId
- Purpose: Update the profile image for a specific user.
- Request Body:
type
: formdatafiles
:name
: imagevalue
: Path to the image file
- Headers:
Authorization
: Bearer token for authentication
- Response:
- 200 OK: Image updated successfully
- 401 Unauthorized: Invalid or missing authentication token
- 403 Forbidden: User lacks permission to update the image
- 404 Not Found: User with specified userId not found
- Endpoint:
GET /update-user-details
- Purpose: Update user information like name.
- Request Body:
{ "name":"Pranav", }
- Response:
- 200 OK: User details updated successfully
- 401 Unauthorized: Invalid or missing authentication token
- 403 Forbidden: User lacks permission to update the name
- 404 Not Found: User with specified userId not found