A backend API for an e-commerce platform built with TypeScript, Node.js, Express, and MongoDB. This project provides authentication, product management, order processing, and cart functionality.
- User registration & login with JWT authentication
- Role-based access control (Admin & User)
- Create, read, update, and delete products (Admin only)
- View all products
- View a single product by ID
- Add products to cart
- Remove/update cart items
- View cart items
- Place an order
- View order details
- Update order status
- Delete an order
- Secure payment processing with Paystack
- JWT authentication for protected routes
- Input validation & error handling
- Backend: Node.js, Express, TypeScript
- Database: MongoDB (Mongoose ODM)
- Authentication: JSON Web Token (JWT)
git clone https://github.com/Nuelchi/TS-E-commerce.git
cd TS-E-commerce@types/passport@types/passport-google-oauth20bcryptbcryptjsdotenvexpressexpress-sessionjsonwebtokenmongodbmongoosepassportpassport-google-oauth20validatoraxios(for Paystack integration)
@types/bcryptjs@types/express@types/express-session@types/jsonwebtoken@types/node@types/validatornodemonts-nodetypescript
npm install ...Create a .env file in the root directory and add the following:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secret_key
PAYSTACK_SECRET_KEY=your_paystack_secret
npm run devServer runs on http://localhost:5000
| Method | Endpoint | Description |
| POST | /api/auth/register | Register a new user |
| POST | /api/auth/login | Login user & get token |
| Method | Endpoint | Description |
| GET | /api/products | Get all products |
| GET | /api/products/:id | Get a single product |
| POST | /api/products | Create product (Admin) |
| PUT | /api/products/:id | Update product (Admin) |
| DELETE | /api/products/:id | Delete product (Admin) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /cart/add |
Add item to cart |
| GET | /cart/getcart |
Get current cart |
| DELETE | /cart/:id |
Remove an item from cart |
| DELETE | /cart/delete/ |
Delete entire cart |
| POST | /user/signup | create a new user |
| POST | /user/login | login a user |
| GET | /users/ | Get all users (admin)|
| Method | Endpoint | Description |
|---|---|---|
| POST | /payment/initialize-payment |
Initialize a payment |
| GET | /payment/verify-payment/:reference |
Verify a payment |
- ✅ Implement unit tests with Jest
- ✅ Deploy the API to production
For inquiries or collaborations:
- GitHub: Nuelchi
- LinkedIn: Emmanuel Nwafor
- Email: edubem80@gmail.com