Skip to content

🚀 Welcome to this Full‑Stack REST API project! This repository houses a Node.js REST API that was built as a comprehensive hands‑on backend application. It showcases a variety of implemented features and thoughtfully designed RESTful endpoints, reflecting my practical experience and growth in building scalable server‑side services.

License

Notifications You must be signed in to change notification settings

rkb32/NodeRESTified

Repository files navigation

Fullstack Bootcamp Node.js Backend Project

GitHub last commit Node.js Version Express.js Version MongoDB Mongoose Version JWT Jest Gravatar Nodemailer

This repository contains a Node.js REST API project that we helped design and build collaboratively. With teammates to plan, implement, and refine the API, applying best practices for scalable and maintainable RESTful service development.

The project covers a range of real‑world backend features including routing, data persistence, validation, and error handling — and represents a core piece of my experience developing robust server‑side applications. It serves as a foundation for future enhancements and full‑stack integrations.

HTTP Requests and JSON Contact Management

focused on working with HTTP requests in a Alt text environment. The project involves managing a Alt text file containing contacts. The application allows performing various operations on the contacts, including:

API Endpoints

  • (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.

Technologies Used

  • Node.js: The runtime environment for executing the application.
  • Express.js: 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.
  • JSON: Data interchange format used in the project.

Node.js, MongoDB, and Mongoose CRUD Backend

It builds upon the previous project, now incorporating MongoDB with Mongoose 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:

API Endpoints

  • (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.

Technologies Used

  • Node.js: The runtime environment for executing the application.
  • MongoDB: A NoSQL database for data persistence.
  • Mongoose: An ODM (Object Data Modeling) library for MongoDB and Node.js.
  • Express.js: A web application framework for building RESTful APIs.
  • JSON: Data interchange format used in the project.

Node.js, MongoDB, Mongoose, and JWT Authentication with Extended Contact Management

This extends the capabilities developed in previous projects, specifically focusing on HTTP requests, JSON contact management, and MongoDB integration. Building upon this foundation, the current module introduces a robust authentication system using JSON Web Token (JWT) and enhances the contact management system with additional features to provide a more comprehensive and secure user experience.

API Endpoints

Contact endpoints

  • (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.

User endpoints

  • (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.

Additional Endpoints

  • (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.

Technologies Used

  • Node.js: The runtime environment for executing the application.
  • MongoDB: A NoSQL database for data persistence.
  • Mongoose: An ODM (Object Data Modeling) library for MongoDB and Node.js.
  • JSON Web Token: Used for user authentication.
  • Express.js: A web application framework for building RESTful APIs.
  • JSON: Data interchange format used in the project.

External REST API Integration, Avatar Management, and Jest Testing

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.

API Endpoints

Contact endpoints

  • (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.

User endpoints

  • (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.

Additional Endpoints

  • (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.

Avatar Management

  • Avatars are automatically generated for new users using the Gravatar 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.

Jest Testing for Login

  • Implements Jest 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.

Technologies Used

  • Node.js: The runtime environment for executing the application.
  • MongoDB: A NoSQL database for data persistence.
  • Mongoose: An ODM (Object Data Modeling) library for MongoDB and Node.js.
  • JSON Web Token: Used for user authentication.
  • Express.js: A web application framework for building RESTful APIs.
  • JSON: Data interchange format used in the project.
  • Jest:JavaScript testing framework ensuring code reliability and simplicity.
  • Gravatar: Global avatar service for user profile images linked to email addresses.

Email Verification with Nodemailer

This, 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.

API Endpoints

Contact endpoints

  • (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.

User endpoints

  • (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.

Additional Endpoints

  • (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.

Technologies Used

  • Node.js: The runtime environment for executing the application.
  • MongoDB: A NoSQL database for data persistence.
  • Mongoose: An ODM (Object Data Modeling) library for MongoDB and Node.js.
  • JSON Web Token: Used for user authentication.
  • Express.js: A web application framework for building RESTful APIs.
  • JSON: Data interchange format used in the project.
  • Nodemailer: Email sending module for Node.js.

Getting Started

Follow these instructions to set up the project on your local machine for development and testing purposes.

Requirements

  • Node.js installed
  • NPM (Node Package Manager) installed

Installing

  1. Clone the repository to your local machine.
    git clone https://github.com/Alexandrbig1/nodejs-rest-api-homework.git
  2. Navigate to the project folder.
    cd nodejs-rest-api-homework
  3. Install dependencies.
    npm install

Running the Application

  • 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

Project API Endpoints

Contact endpoints

  • (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.

User endpoints

  • (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.

Additional Endpoints

  • (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.

Feedback

I welcome feedback and suggestions from users to improve the application's functionality and user experience.

Languages and Tools:

About

🚀 Welcome to this Full‑Stack REST API project! This repository houses a Node.js REST API that was built as a comprehensive hands‑on backend application. It showcases a variety of implemented features and thoughtfully designed RESTful endpoints, reflecting my practical experience and growth in building scalable server‑side services.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors