Welcome to the Contact Manager App Backend! This is a backend server built for managing contacts, providing secure user authentication and CRUD operations for contacts. It's designed to allow users to manage their contact information while ensuring security through authentication middleware.
- User Authentication: Secure sign-up, login, and logout functionality.
- CRUD Operations: Create, Read, Update, and Delete operations for managing contacts.
- Secure Endpoints: Protected routes utilizing authentication middleware to ensure secure access.
- API Documentation: Comprehensive documentation to help you interact with the API.
- Node.js: Server-side JavaScript runtime.
- Express.js: Web application framework for Node.js.
- MongoDB: NoSQL database to store user and contact information.
- JSON Web Tokens (JWT): Used for user authentication and managing sessions.
- bcrypt: Secure password hashing and comparison for authentication.
https://github.com/SkamAbhi/mycontacts-backend.gitnpm installCreate a .env file in the root directory of the project and add the following variables:
PORT=<your_port>
CONNECTION_STRING=<your_database_connection_string>
ACCESS_TOKEN_SECRET=<your_jwt_secret_key>npm start- URL:
/api/users/register - Method:
POST - Body Parameters:
user(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/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, optional): Contact's name.email(string, optional): Contact's email address.phone(string, optional): Contact's phone number.
- URL:
/api/contacts/:contactId - Method:
DELETE - Headers:
Authorization: Bearer token obtained after logging in.
- All endpoints except the sign-up and login require an authentication token obtained after logging in.
- Tokens should be sent in the
Authorizationheader as aBearer token.