This repository contains a REST API project developed during my full-stack bootcamp. The project spans from the 2nd homework assignment to the 6th and serves as a practical implementation of the concepts covered in the bootcamp. It provides a foundation for building scalable and robust RESTful web services.
- Homework2
- Homework3
- Homework4
- Homework5
- Homework6
- Getting Started
- API Endpoints
- Issues
- Acknowledgments
The second homework assignment focuses on working with HTTP requests in a environment. The project involves managing a file containing contacts. The application allows performing various operations on the contacts, including:
- (GET)
/api/contacts
: Retrieve a list of all contacts. - (GET)
/api/contacts/
:contactId: Retrieve a specific contact by ID. - (POST)
/api/contacts
: Add a new contact to the list. - (PUT)
/api/contacts/
:contactId: Update an existing contact's information. - (DELETE)
/api/contacts/
:contactId: Delete an existing contact from the list.
- : The runtime environment for executing the application.
- : A web application framework for building RESTful APIs.
- Cors: Middleware for handling Cross-Origin Resource Sharing in Express.js applications.
- Morgan: HTTP request logger middleware for Express.js.
- UUID: Used for generating unique IDs for various purposes.
- : Data interchange format used in the project.
The third homework assignment builds upon the previous project, now incorporating with for data persistence. The application manages contacts stored in a MongoDB database and allows users to perform various operations on the contacts. The supported CRUD operations include:
- (GET)
/api/contacts
: Retrieve a list of all contacts. - (GET)
/api/contacts/
:contactId: Retrieve a specific contact by ID. - (POST)
/api/contacts
: Add a new contact to the list. - (PUT)
/api/contacts/
:contactId: Update an existing contact's information. - (PATCH)
/api/contacts/
:contactId/favorite: Partially update an existing contact's information. - (DELETE)
/api/contacts/
:contactId: Delete an existing contact from the list.
- : The runtime environment for executing the application.
- : A NoSQL database for data persistence.
- : An ODM (Object Data Modeling) library for MongoDB and Node.js.
- : A web application framework for building RESTful APIs.
- : Data interchange format used in the project.
The fourth homework assignment extends the capabilities developed in previous projects, specifically focusing on HTTP requests, contact management, and integration. Building upon this foundation, the current module introduces a robust authentication system using (JWT) and enhances the contact management system with additional features to provide a more comprehensive and secure user experience.
- (GET)
/api/contacts
: Retrieve a list of all contacts. - (GET)
/api/contacts/
:contactId: Retrieve a specific contact by ID. - (POST)
/api/contacts
: Add a new contact to the list. - (PUT)
/api/contacts/
:contactId: Update an existing contact's information. - (PATCH)
/api/contacts/
:contactId/favorite: Partially update an existing contact's information. - (DELETE)
/api/contacts/
:contactId: Delete an existing contact from the list.
- (POST)
/api/users/signup
: Register a new user. - (POST)
/api/users/signin
: Login and obtain a JWT. - (POST)
/api/users/logout
: Logout the user. - (GET)
/api/users/current
: Retrieve information about the currently logged-in user.
- (GET)
/api/contacts?page=<page_number>&limit=<page_size>
: Retrieve paginated contacts. - (GET)
/api/contacts?favorite=true
: Retrieve contacts marked as favorites. - (PATCH)
/api/users
: Update the user's subscription level.
- : The runtime environment for executing the application.
- : A NoSQL database for data persistence.
- : An ODM (Object Data Modeling) library for MongoDB and Node.js.
- : Used for user authentication.
- : A web application framework for building RESTful APIs.
- : Data interchange format used in the project.
The fifth homework assignment builds upon the solid foundation of previous projects, expanding the capabilities of the application to include external REST API integration, avatar management, and Jest testing for enhanced functionality and reliability.
- (GET)
/api/contacts
: Retrieve a list of all contacts. - (GET)
/api/contacts/
:contactId: Retrieve a specific contact by ID. - (POST)
/api/contacts
: Add a new contact to the list. - (PUT)
/api/contacts/
:contactId: Update an existing contact's information. - (PATCH)
/api/contacts/
:contactId/favorite: Partially update an existing contact's information. - (DELETE)
/api/contacts/
:contactId: Delete an existing contact from the list.
- (POST)
/api/users/signup
: Register a new user. - (POST)
/api/users/signin
: Login and obtain a JWT. - (POST)
/api/users/logout
: Logout the user. - (GET)
/api/users/current
: Retrieve information about the currently logged-in user. - (PATCH)
/api/users/avatars
: Change the user's avatar.
- (GET)
/api/contacts?page=<page_number>&limit=<page_size>
: Retrieve paginated contacts. - (GET)
/api/contacts?favorite=true
: Retrieve contacts marked as favorites. - (PATCH)
/api/users
: Update the user's subscription level.
- Avatars are automatically generated for new users using the package.
- Introduces a new endpoint
(PATCH) /api/users/avatars
for users to change their avatars. - Jimp package is utilized for image processing related to avatars.
- Implements testing to ensure the robustness of the login functionality.
- Unit tests are created to validate the authentication system, enhancing the overall reliability of the application.
- Run tests using
npm run test
script defined in the package.json file.
- : The runtime environment for executing the application.
- : A NoSQL database for data persistence.
- : An ODM (Object Data Modeling) library for MongoDB and Node.js.
- : Used for user authentication.
- : A web application framework for building RESTful APIs.
- : Data interchange format used in the project.
- :JavaScript testing framework ensuring code reliability and simplicity.
- : Global avatar service for user profile images linked to email addresses.
The sixth homework assignment builds upon prior projects, introduces a crucial featureβemail verification using the Nodemailer API. This module is dedicated to fortifying user security and refining access control within our application.
- (GET)
/api/contacts
: Retrieve a list of all contacts. - (GET)
/api/contacts/
:contactId: Retrieve a specific contact by ID. - (POST)
/api/contacts
: Add a new contact to the list. - (PUT)
/api/contacts/
:contactId: Update an existing contact's information. - (PATCH)
/api/contacts/
:contactId/favorite: Partially update an existing contact's information. - (DELETE)
/api/contacts/
:contactId: Delete an existing contact from the list.
- (POST)
/api/users/signup
: Register a new user. - (POST)
/api/users/signin
: Login and obtain a JWT. - (POST)
/api/users/logout
: Logout the user. - (GET)
/api/users/current
: Retrieve information about the currently logged-in user. - (PATCH)
/api/users/avatars
: Change the user's avatar. - (GET)
/api/users/verify/:verificationToken
: Verify the user's email address using the provided token. - (POST)
/api/users/verify
: Request a second verification email.
- (GET)
/api/contacts?page=<page_number>&limit=<page_size>
: Retrieve paginated contacts. - (GET)
/api/contacts?favorite=true
: Retrieve contacts marked as favorites. - (PATCH)
/api/users
: Update the user's subscription level.
- : The runtime environment for executing the application.
- : A NoSQL database for data persistence.
- : An ODM (Object Data Modeling) library for MongoDB and Node.js.
- : Used for user authentication.
- : A web application framework for building RESTful APIs.
- : Data interchange format used in the project.
- : Email sending module for Node.js.
Follow these instructions to set up the project on your local machine for development and testing purposes.
- Node.js installed
- NPM (Node Package Manager) installed
- Clone the repository to your local machine.
git clone https://github.com/Alexandrbig1/nodejs-rest-api-homework.git
- Navigate to the project folder.
cd nodejs-rest-api-homework
- Install dependencies.
npm install
- Production Mode:
npm start
- Development Mode with Nodemon:
npm run dev
- Running Tests
To execute unit tests using Jest, use the following command:
npm run test
- (GET)
/api/contacts
: Retrieve a list of all contacts. - (GET)
/api/contacts/
:contactId: Retrieve a specific contact by ID. - (POST)
/api/contacts
: Add a new contact to the list. - (PUT)
/api/contacts/
:contactId: Update an existing contact's information. - (PATCH)
/api/contacts/
:contactId/favorite: Partially update an existing contact's information. - (DELETE)
/api/contacts/
:contactId: Delete an existing contact from the list.
- (POST)
/api/users/signup
: Register a new user. - (POST)
/api/users/signin
: Login and obtain a JWT. - (POST)
/api/users/logout
: Logout the user. - (GET)
/api/users/current
: Retrieve information about the currently logged-in user. - (PATCH)
/api/users/avatars
: Change the user's avatar. - (GET)
/api/users/verify/:verificationToken
: Verify the user's email address using the provided token. - (POST)
/api/users/verify
: Request a second verification email.
- (GET)
/api/contacts?page=<page_number>&limit=<page_size>
: Retrieve paginated contacts. - (GET)
/api/contacts?favorite=true
: Retrieve contacts marked as favorites. - (PATCH)
/api/users
: Update the user's subscription level.
If you encounter any issues or have suggestions, please open an issue.
I welcome feedback and suggestions from users to improve the application's functionality and user experience.
I extend my sincere gratitude to the entire team at GoIT for their unwavering guidance and support during my enriching journey through the Fullstack Bootcamp. This comprehensive 10-month program has equipped me with valuable skills across various modules, and I am particularly grateful for the in-depth learning experience in Node.js, which serves as the final module in this transformative bootcamp.