This repository contains an E-commerce API built with Express, TypeScript, Mongoose, and Zod validation. It provides basic CRUD operations for managing products and orders. The project is configured with ESLint and Prettier for code quality and consistency.
Live server: Link
- Express.js for handling HTTP requests and routing
- TypeScript for type-safe JavaScript
- Mongoose for MongoDB object modeling
- Zod for schema validation
- Basic CRUD operations for products and orders
- ESLint and Prettier for code linting and formatting
Make sure you have the following installed:
- Node.js (>=14.x)
- npm or yarn
- MongoDB
-
Clone the repository:
https://github.com/justJubair/express-server-phero.git cd express-server-phero
-
Install dependencies:
npm install # or yarn install
-
Create a
.env
file in the root directory and add your MongoDB connection string:MONGO_URI=mongodb://localhost:27017/your-database-name PORT=5000
Start the development server:
npm run start:dev
# or
yarn start:dev
The server will be running on http://localhost:5000
.
To lint your code:
npm run lint
# or
yarn lint
To format your code:
npm run lint:fix
# or
yarn lint:fix
GET /api/products
- Get all productsGET /api/products/:productId
- Get a single product by IDPOST /api/products
- Create a new productPUT /api/products/:productId
- Update a product by IDDELETE /api/products/:productId
- Delete a product by IDSEARCH /api/products?searchTerm=iphone
- Delete a product by ID
GET /api/orders
- Get all ordersGET By User Email api/orders?email=jubair@gmail.com
- Get a single order by IDPOST /api/orders
- Create a new order
ecommerce-api/
│
├── src/
│ ├── app/
│ │ ├── config/
│ │ │ └── index.ts
│ │ ├── modules/
│ │ │ ├── order/
│ │ │ │ ├── order.controller.ts
│ │ │ │ ├── order.interface.ts
│ │ │ │ ├── order.model.ts
│ │ │ │ ├── order.route.ts
│ │ │ │ ├── order.service.ts
│ │ │ │ └── order.validation.ts
│ │ │ ├── product/
│ │ │ │ ├── product.controller.ts
│ │ │ │ ├── product.interface.ts
│ │ │ │ ├── product.model.ts
│ │ │ │ ├── product.route.ts
│ │ │ │ ├── product.service.ts
│ │ │ │ └── product.validation.ts
│ ├── app.ts
│ └── server.ts
├── .eslintrc.js
├── .prettierrc
├── tsconfig.json
├── package.json
└── README.md
Contributions are welcome! Please open an issue or submit a pull request for any bugs or improvements.
If you have any questions, feel free to reach out:
- Email: jubair.ahmed2838@gmail.com
- LinkedIn: LinkedIn
Happy coding! 🚀