A modern, scalable REST API for a bike store built with Node.js, Express, TypeScript, and MongoDB. This API provides comprehensive CRUD operations for managing bikes, orders, users, and authentication with JWT.
- 🔐 JWT Authentication - Secure user authentication and authorization
- 🚲 Product Management - Full CRUD operations for bike products
- 📦 Order Management - Handle customer orders and revenue tracking
- 👥 User Management - User registration, login, and profile management
- 💳 Payment Integration - ShurjoPay payment gateway integration
- 📝 Message System - Internal messaging functionality
- 🛡️ Input Validation - Zod schema validation for all endpoints
- 🔒 Security - Password hashing with bcrypt, CORS protection
- 📊 Error Handling - Comprehensive error handling and logging
- 🎨 Code Quality - ESLint and Prettier for code formatting
- Runtime: Node.js
- Framework: Express.js
- Language: TypeScript
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcrypt
- Validation: Zod
- Payment: ShurjoPay
- Package Manager: npm
- Code Quality: ESLint, Prettier
- Development Server: ts-node-dev
- Type Checking: TypeScript
- Node.js (v18 or higher)
- npm or yarn
- MongoDB database
-
Clone the repository
git clone <repository-url> cd bike-store
-
Install dependencies
npm install
-
Environment Setup Create a
.envfile in the root directory:PORT=5000 MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret_key NODE_ENV=development
-
Run the application
# Development mode npm run start:dev # Production build npm run build npm start
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/auth/register |
Register a new user |
POST |
/api/auth/login |
User login |
POST |
/api/auth/logout |
User logout |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/products |
Create a new bike product |
GET |
/api/products |
Get all bike products |
GET |
/api/products/:id |
Get a specific bike product |
PUT |
/api/products/:id |
Update a bike product |
DELETE |
/api/products/:id |
Delete a bike product |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/orders |
Create a new order |
GET |
/api/orders |
Get all orders |
GET |
/api/orders/:id |
Get a specific order |
GET |
/api/revenue |
Get revenue statistics |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/users |
Get all users |
GET |
/api/users/:id |
Get a specific user |
PUT |
/api/users/:id |
Update user profile |
DELETE |
/api/users/:id |
Delete a user |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/messages |
Send a message |
GET |
/api/messages |
Get all messages |
src/
├── app/
│ ├── config/ # Configuration files
│ ├── middleware/ # Custom middleware
│ ├── modules/ # Feature modules
│ │ ├── auth/ # Authentication module
│ │ ├── message/ # Message module
│ │ ├── order/ # Order module
│ │ ├── product/ # Product module
│ │ └── user/ # User module
│ └── global-error-handler.ts
├── utils/ # Utility functions
├── app.ts # Express app configuration
└── server.ts # Server entry point
| Script | Description |
|---|---|
npm run start:dev |
Start development server with hot reload |
npm run build |
Build the project for production |
npm start |
Start production server |
npm run lint |
Run ESLint to check code quality |
npm run lint:fix |
Fix ESLint errors automatically |
npm run prettier |
Format code with Prettier |
npm run prettier:fix |
Fix Prettier formatting issues |
API Base URL: https://bike-store-nine.vercel.app/
- JWT-based authentication
- Password hashing with bcrypt
- CORS protection
- Input validation with Zod
- Error handling middleware
- Secure HTTP headers
| Variable | Description | Required |
|---|---|---|
PORT |
Server port number | Yes |
MONGODB_URI |
MongoDB connection string | Yes |
JWT_SECRET |
Secret key for JWT tokens | Yes |
NODE_ENV |
Environment (development/production) | No |
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
Your Name
- GitHub: @yourusername
- Express.js team for the amazing framework
- MongoDB team for the database
- TypeScript team for the type safety
- All contributors and maintainers
⭐ Star this repository if you found it helpful!