Skip to content

ralitsavoronevska/rest-api-with-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Node.js REST API Project (Build a simple shop API)

I've built a simple REST API in Node.js with a MVC software architecture simulating a basic shop API by following the Building a RESTful API Academind Course course.
It was an optional side course suggested in the main course I was taking at the time - Vue - The Complete Guide (incl. Router & Composition API) Udemy course.

Diagram

Routes


Project Specifics:

  • Core Runtime: Node.js (v20.19.5 for modern ES modules and async/await support).
  • API Framework: Express.js for routing and middleware handling with endpoints for CRUD operations (Create, Read, Update, Delete) on items such as users, products or orders, emphasizing API design principles like statelessness, resource-based routing, and HTTP methods (GET, POST, PUT, DELETE).
  • Tools: Nodemon - automatically restarting the Node.js application when file changes in the directory are detected.
  • Database: MongoDB Atlas together with Mongoose for the object modeling in the MVC software architecture of the API project.
  • APIs: Postman for testing the API project by providing a user-friendly interface for making requests, viewing responses, and debugging issues.
  • Middlewares:
    • Multer is the Node.js middleware for handling multipart/form-data in this API project, which is primarily used for uploading files for products.
    • express-async-handler - for handling exceptions inside of async express routes and passing them to the express error handlers.
    • Mongan - HTTP request logger middleware for Node.js
  • Authentication: JSON Web Token (JWT) together with bcrypt for hashing passwords.
  • Other: The project is using body-parser package to parse the body of an incoming requests, because it's not nicely formatted and easily readable by default in Node.js. As a result we can then use the formatted data of the body of an incoming requests. The package doesnt support files, but it supports URL encoded bodies and json data.

Main Features:

  • Authentication of users.
  • Endpoints for signin and logging for users:
    • /signup,
    • /login.
  • Endpoints for managing shop inventory and orders:
    • /products for listing items,
    • /products/:id for individual product details,
    • /orders for listing orders,
    • /orders/:id for individual order details.
  • Basic error handling and response formatting.

📸 Screenshots

🔐🔑 Operations that need Authentication

Sign Up:

Log in:

Post Product:

Post Orders:

Get New Order:

Get All Orders:

Update Product:

Delete Product:

Delete Order:

🔓 Operations that DO NOT need Authentication

Get New Product:

Get New Product Image:

GET All Products:

Setup

Make sure to install the dependencies:

$ npm i

Development Server

Start the development server:

$ npm run start

🌟 Inspiration & Credits:

▶️ Vue - The Complete Guide (incl. Router & Composition API)
📂 Building a RESTful API Academind Course
🎞️ Building a RESTful API with Node.js Academind [Youtube]
🪁 JWT Debugger
📊 GitDiagram


🙌 Thanks for checking out my project! More coming 🔜.
Stay tuned 🚀 and don't forget to give the project a star!
⭐ Made with lots of 💗, ☕, and a sprinkle of ✨ by Ralitsa Voronevska!

Releases

No releases published

Packages

No packages published