Features • Technologies • Getting Started • Usage • Support • License
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. 👨🍳🍰
-
🛍️ 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.
This project was developed with the following technologies:
Project Dependencies:
Dev Dependencies:
- @types/bcrypt
- @types/cors
- @types/express
- @types/jsonwebtoken
- @types/multer
- @types/node
- @types/swagger-ui-express
- nodemon
- ts-node
- typescript
-
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.
Uploaded images can be stored in the cloud using Cloudinary. To do this, follow the steps below:
- Create a Cloudinary environment here.
- Retrieve the
cloud name
,API key
, andAPI secret
, then set them in the.env
file (see the section Config .env variables).
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
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 belocal
orcloudinary
(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).
To run it, follow the steps below:
# Install dependencies
npm install
# Seed the database
npm run seed
# Run the project
npm run dev
-
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:
- Create an account using the
/api/auth/signup
endpoint. - Retrieve the JWT token received in the response.
- Include the token in the
Authorization
header of your requests.
- Create an account using the
-
To access admin routes:
- Log in using the
/api/auth/login
endpoint with the following credentials:Email: [email protected] Password: joaciadmin
- Retrieve the JWT token received in the response.
- Include the token in the
Authorization
header of your requests.
- Log in using the
To morally and mentally support the project, make sure to leave a ⭐️!
This project is under MIT license