- PostgreSQL
- Kysely / Drizzle
- Prisma
- NestJS
- TypeScript
- Prettier
- ESLint
- Authentication endpoints (sign up, sign in, sign out, forgot, reset password)
- List products with pagination
- Search products by category
- Add 2 kinds of users (Manager, Client)
- As a Manager I can:
- ✅Create products
- ✅Update products
- ✅Delete products
- ✅Disable products
- ✅Show clients' orders
- ✅Upload images per product
- As a Client I can:
- ✅See products
- ✅See the product details
- ✅Buy products
- ✅Add products to cart
- ✅Like products
- ✅Show my order
- ✅The product information (including images) should be visible to both logged-in and not logged-in users
- Stripe Integration ✅for payment (including webhook management)
- ✅Schema validation for environment variables
- ✅Usage of global exception filter
- ✅Usage of guards, pipes (validation)
- ✅Usage of custom decorators
- ✅Configure helmet, CORS, rate limiting (for reset password feature)
- ⚰️Implement resolve field in GraphQL queries (if applicable)
- ⚰️When the stock of a product reaches 3, notify the last user who liked it but hasn't purchased it yet with an email, including the product's image. Use a background job for this task.
- ✅Send an email when the user changes their password
- ⚰️Deploy on Heroku
Requirements to use REST:
- Authentication endpoints (sign up, sign in, sign out, forgot, reset password)
- Stripe Integration for payment (including webhook management)
Requirements to use GraphQL:
- All features not listed under the REST requirements
Shoes-API is a nodeJs/NestJseducational project designed to demonstrate modern technologies, best practices, and design patterns in software development. It showcases a complete workflow from backend to frontend, using industry-standard tools and frameworks.
Ensure you have the following installed:
- Node.js (v14 or later)
- npm (Node Package Manager) or yarn
- PostgreSQL (Database OR use docker)
- Clone the repository:
git clone <code that you copied from the repositorie>
In this part, you need to add your environment variables that will be used for the API.
-
Cloudinary: You will need a Cloudinary account to get your own credentials. Paste them into the
.env
file and remove the.sample
provided. -
define the
JWT_SECRET
=261bb2f1d8161e6ae1b9c49045f1ecc9c5890cf6f098266e17bb9fba76b813402cc170100a017ca54e8dbc973b2303e75fd6ae14d3af482f893c73c866b5c87ada2912ee165054463f51462f8688c3e1b27060c8027a850315d945290fa6f08eb4953bd55b2bd67819c88ab9500fd685dd90f11e7f54a33d5adb8a252fe1f923e59d984b8a26bec148ad9bad237252538fb08644f7c057c46087e7081ec5a66bd9131b784ffaad0d74fdd68fed539d2dd41002a4417efc587d2dd431ca714b7728516dce3e7f18ef24833ecd847ec7d5c45e2cb9f0608d600987b0ec742fdf36
AND JWTEXPIRATION
=14400
fields -
Database Configuration (using Docker): If you are using Docker, follow these steps to properly configure your PostgreSQL database.
- Create a
docker-compose.yml
file with the following content:
version: '3.8'
services:
postgres_container:
image: postgres:17
container_name: postgres_container
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
networks:
- my_network
ports:
- "5432:5432"
pgadmin4_container:
image: dpage/pgadmin4
container_name: pgadmin4_container
environment:
PGADMIN_DEFAULT_EMAIL: admin@admin.com
PGADMIN_DEFAULT_PASSWORD: admin
networks:
- my_network
ports:
- "5050:80" # Or your preference
networks:
my_network:
driver: bridge
- After creating the
docker-compose.yml
file, run the following command to bring up the Docker containers:
docker-compose up
This will create the PostgreSQL and pgAdmin containers.
- Find your PostgreSQL container's IP address using:
docker inspect postgres_container
Look for the "IPAddress": "your_corresponding_IP"
and note it down.
- Configure your server to connect to the PostgreSQL instance using the IP address you retrieved.
-
Install Dependencies: Open your IDE and run the following command to install all the necessary dependencies:
npm i
-
Generate Prisma Client: Next, generate the Prisma client by running:
npx prisma generate
-
Seed Database: Finally, seed the database with sample data by running:
npm run seeds
If you want to use the routes for clients you need to do the following:
- Open your favorite app to test APIs (like postman or insomnia)
- define your base Url or put the local post you are working on directly:
and add this into the body:
{
"firstName": "testing",
"lastName": "test",
"userName": "testing",
"address": "street test1",
"email":"test8@gmail.com",
"password":"test"
}
(changes variables)
- you gonna recieve something like this:
- login
- copy the acces token an put it on the auth (bearer)
- now, you´re available to acces to the client routes
if you want to acces to manager routes you need to run the seed and do the login with the credentials
This project is licensed under the MIT License. See the LICENSE file for details.