A RESTful API for e-commerce applications built with Express.js, TypeScript, and PostgreSQL. This API provides endpoints for product management, user authentication, order processing, and Stripe payment integration.
- Product Management: Create, read, update, and delete products
- User Authentication: Register, login, and JWT-based authentication
- Order Processing: Create and manage orders
- Payment Integration: Process payments using Stripe
- Database: PostgreSQL with Drizzle ORM
- API Documentation: Detailed API endpoints
- TypeScript: Type-safe code
- Backend: Node.js, Express.js
- Language: TypeScript
- Database: PostgreSQL
- ORM: Drizzle ORM
- Authentication: JWT, bcrypt
- Payment: Stripe
- Deployment: Serverless ready
- Node.js (v18 or higher)
- PostgreSQL database
- Stripe account (for payment processing)
-
Clone the repository:
git clone https://github.com/enzocandido/ecommerce-api.git cd ecommerce-api -
Install dependencies:
npm install
-
Set up environment variables:
cp .env.example .env
Then edit
.envwith your configuration details. -
Generate database migrations:
npm run db:generate
-
Run migrations:
npm run db:migrate
Start the development server:
npm run devThe API will be available at http://localhost:3001.
- Generate migrations:
npm run db:generate - Run migrations:
npm run db:migrate - Explore database with Drizzle Studio:
npm run db:studio
POST /auth/register- Register a new userPOST /auth/login- Login and receive an access token
GET /products- Get all productsGET /products/:id- Get a specific productPOST /products- Create a new productPUT /products/:id- Update a productDELETE /products/:id- Delete a product
GET /orders- Get user's ordersGET /orders/:id- Get a specific orderPOST /orders- Create a new order
POST /stripe/create-payment-intent- Create a payment intentPOST /stripe/webhook- Handle Stripe webhook events
This project is configured for serverless deployment. The handler export in index.ts can be used with services like AWS Lambda, Vercel, or Netlify.