Welcome to the Contact Manager App Backend! This application provides a backend server for managing contacts. It includes authentication features and CRUD operations for contacts.
- User authentication: Users can sign up, log in, and log out securely.
- Create, Read, Update, Delete (CRUD) operations for contacts.
- Secure endpoints with authentication middleware.
- API documentation available.
- Node.js
- Express.js
- MongoDB (or your preferred database)
- JSON Web Tokens (JWT) for authentication
- bcrypt for password hashing
- Clone the repository:
git clone https://github.com/arjunbector/Contact-Manager-Backend.git- Install dependencies:
npm install- Set up environment variables:
Create a .env file in the root directory and add the following variables:
MONGODB_URI=<your_database_connection_string>
ACCESS_TOKEN_SECRET=<your_jwt_secret_key>
ACCESS_TOKEN_EXPIRY=1d
REFRESH_TOKEN_SECRET=<your_jwt_secret_key>
REFRESH_TOKEN_EXPIRY=30d
- Start the server:
npm startThe server will start running on the specified port.
- URL:
/api/users/register - Method:
POST - Body Parameters:
username(string): User's username.email(string): User's email address.password(string): User's password.
- URL:
/api/users/login - Method:
POST - Body Parameters:
email(string): User's email address.password(string): User's password.
- URL :
/api/users/update - Method:
PUT - Headers:
Authorization: Bearer token obtained after logging in.
- URL:
/api/auth/logout - Method:
GET - Headers:
Authorization: Bearer token obtained after logging in.
- URL:
/api/contacts - Method:
GET - Headers:
Authorization: Bearer token obtained after logging in.
- URL:
/api/contacts/:contactId - Method:
GET - Headers:
Authorization: Bearer token obtained after logging in.
- URL:
/api/contacts - Method:
POST - Headers:
Authorization: Bearer token obtained after logging in.
- Body Parameters:
name(string): Contact's name.email(string): Contact's email address.phone(string): Contact's phone number.
- URL:
/api/contacts/:contactId - Method:
PUT - Headers:
Authorization: Bearer token obtained after logging in.
- Body Parameters:
name(string): Contact's name.email(string): Contact's email address (optional).phone(string): Contact's phone number (optional).
- URL:
/api/contacts/:contactId - Method:
DELETE - Headers:
Authorization: Bearer token obtained after logging in.