Skip to content

A powerful REST API designed to manage a fictional online cake store, built with Node.js, TypeScript, Express, MongoDB, Cloudinary, and Swagger UI.

License

Notifications You must be signed in to change notification settings

JoaciFaustino/api-cake-ecommerce

Repository files navigation

Cake E-commerce API

FeaturesTechnologiesGetting StartedUsageSupportLicense

Cake E-commerce API is a powerful REST API designed to manage a fictional online cake store, inspired by the world of confectionery. This project was born from a mix of curiosity and personal connection, making it both a learning experience and a tribute to the art of baking. 👨‍🍳🍰

✨ Features

  • 🛍️ Product Management – Creation, update, and deletion of cakes, as well as management of cake types, categories, frostings, and fillings. These actions are properly protected so that only admins can perform them. Product listings are available to all users, with pagination, search, and multiple sorting and filtering options.

  • 📄 File Upload – Supports image uploads, storing them either in the cloud or serving them directly from the server.

  • 🛒 Order Management – Management of delivery dates and order statuses with advanced filtering and sorting options. Admin users have full order visibility, while individual users can access their own. This system focuses on order management and does not include payment features.

  • 👤 User Authentication – Secure user registration and login using JWT (JSON Web Token) and role-based access control.

  • 📦 Cart System – Add, remove, and update items in the shopping cart, with support for customizations based on each cake’s specific rules.

🧪 Technologies

This project was developed with the following technologies:

Project Dependencies:

Dev Dependencies:

🚀 Getting started

Prerequisites

Database

  • Create a MongoDB database and put the connection URL in the .env file (see the section Config .env variables).

  • Recommendation: Use MongoDB Atlas to host your database in the cloud.

  • Make sure to add your IP address to the list of allowed IPs to access the database.

Cloudinary environment (Optional)

Uploaded images can be stored in the cloud using Cloudinary. To do this, follow the steps below:

  1. Create a Cloudinary environment here.
  2. Retrieve the cloud name, API key, and API secret, then set them in the .env file (see the section Config .env variables).

Cloning

To clone the project, follow the steps below:

# Clone the project
$ git clone https://github.com/JoaciFaustino/api-cake-ecommerce.git

# Access the project folder
$ cd api-cake-ecommerce

Config .env variables

Use the .env.example file as a reference to create your own .env configuration file in the root of the project.

  • PORT: The HTTP port to listen on (Default: 3001).
  • DATABASE_URL: The URL of your MongoDB database.
  • JWT_SECRET: A SHA-256 hash is recommended for security, but it can be any text.
  • API_PROTOCOL: The protocol used by your API. Required only in the production environment (Default: http).
  • API_HOST: The host of your API. Required only in the production environment (Default: localhost).
  • DESTINATION_STORAGE_IMAGES: Where uploaded images are stored. It can be local or cloudinary (Default: local).
  • CLOUD_NAME: The name of your Cloudinary environment (Optional).
  • CLOUDINARY_API_KEY: The API key for your Cloudinary environment (Optional).
  • CLOUDINARY_API_SECRET: The API secret for your Cloudinary environment (Optional).

Starting

To run it, follow the steps below:

# Install dependencies
npm install

# Seed the database
npm run seed

# Run the project
npm run dev

💡 Usage

  • To see all the endpoints in detail, open the Swagger UI at http://localhost:3001/api/docs in your browser (replace 3001 with the port you set in the .env file).

  • To use authenticated endpoints:

    1. Create an account using the /api/auth/signup endpoint.
    2. Retrieve the JWT token received in the response.
    3. Include the token in the Authorization header of your requests.
  • To access admin routes:

    1. Log in using the /api/auth/login endpoint with the following credentials:
      Email: [email protected]
      Password: joaciadmin
      
    2. Retrieve the JWT token received in the response.
    3. Include the token in the Authorization header of your requests.

💖 Support

To morally and mentally support the project, make sure to leave a ⭐️!

📃 License

This project is under MIT license

About

A powerful REST API designed to manage a fictional online cake store, built with Node.js, TypeScript, Express, MongoDB, Cloudinary, and Swagger UI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published