Check out our Live Link
A professional and highly efficient backend system designed for seamless management of a Car Store. Built with Express and TypeScript, this application is seamlessly integrated with MongoDB via Mongoose, ensuring robust data management and consistency. With comprehensive schema validation and a well-structured framework, it delivers reliability, scalability, and performance for handling all Car Store operations effortlessly.
-TypeScript for strong typing and enhanced developer experience.
-Express.js for creating the server and APIs.
-MongoDB for database management using Mongoose.
-Environment Variable management with dotenv
.
-Linting and Formatting with ESLint and Prettier.
-ShurjoPay for payment integration.
-Development server with ts-node-dev for live reload.
-Modular architecture for scalability.
- JWT-based authentication is used to secure user access. An access token is issued for short-term use to access protected resources, while a refresh token allows the user to obtain a new access token without re-login once it expires. The refresh token is securely stored and can be used to refresh the access token as needed.
Make sure you have the following installed:
- Node.js (version 16 or above)
- npm or yarn
- MongoDB instance (local or cloud-based)
-
Clone the repository:
git clone <repository-url> cd <repository-folder>
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory and configure your environment variables:PORT=3000 DATABASE_URL= your-mongodb-uri NODE_ENV=development BCRYPT_SALT_ROUND= Any Number JWT_ACCESS_SECRET= JWT_REFRESH_SECRET= JWT_ACCESS_EXPIRES_IN=10d JWT_REFRESH_EXPIRES_IN=365d RESET_PASSWORD_UI_LINK=http://localhost:5000 IMAGEBB_API_KEY= SP_ENDPOINT=https://sandbox.shurjopayment.com SP_USERNAME=sp_sandbox SP_PASSWORD= SP_PREFIX=SP SP_RETURN_URL=http://localhost:5173/verification
-
Start Development Server:
npm run start:dev
-
Build for Production:
npm run build
-
Start Production Server:
npm run start:prod
-
Lint Code:
npm run lint
-
Fix Lint Issues:
npm run lint:fix
-
Format Code with Prettier:
npm run prettier
-
Fix Formatting Issues:
npm run prettier:fix
car-store-backend/
├── src/
│ ├── app/
│ │ ├── builder/
│ │ │ └── QueryBuilder.ts
│ │ ├── config/
│ │ │ └── index.ts
│ │ ├── errors/
│ │ │ ├── AppError.ts
│ │ │ ├── handleZodError.ts
│ │ │ └── handleCastError.ts
│ │ ├── interface/
│ │ │ ├── events.ts
│ │ │ └── index.d.ts
│ │ ├── middlewares/
│ │ │ ├── auth.ts
│ │ │ └── globalErrorHandler.ts
│ │ ├── route/
│ │ │ └── index.ts
│ │ ├── utils/
│ │ │ ├── CatchAsync.ts
│ │ │ └── sendResponse.ts
│ ├── module/
│ │ ├── Car/
│ │ │ ├── controller.ts
│ │ │ ├── interface.ts
│ │ │ ├── model.ts
│ │ │ ├── route.ts
│ │ │ ├── validation.ts
│ │ │ └── service.ts
│ │ ├── Auth/
│ │ │ ├── controller.ts
│ │ │ ├── interface.ts
│ │ │ ├── model.ts
│ │ │ ├── route.ts
│ │ │ ├── validation.ts
│ │ │ └── service.ts
│ │ ├── Cart/
│ │ │ ├── controller.ts
│ │ │ ├── interface.ts
│ │ │ ├── model.ts
│ │ │ ├── route.ts
│ │ │ ├── validation.ts
│ │ │ └── service.ts
│ │ ├── Order/
│ │ │ ├── controller.ts
│ │ │ ├── interface.ts
│ │ │ ├── model.ts
│ │ │ ├── route.ts
│ │ │ ├── validation.ts
│ │ │ └── service.ts
│ │ ├── Review/
│ │ │ ├── controller.ts
│ │ │ ├── interface.ts
│ │ │ ├── model.ts
│ │ │ ├── route.ts
│ │ │ ├── validation.ts
│ │ │ └── service.ts
│ │ ├── User/
│ │ │ ├── interface.ts
│ │ │ ├── model.ts
│ │ │ └── validation.ts
│ ├── app.ts
│ ├── server.ts
├── dist/ # Compiled JavaScript files
├── .env # Environment variables
├── .eslintrc.config.mjs # ESLint configuration
├── .prettierrc # Prettier configuration
├── package.json # Project dependencies and scripts
├── tsconfig.json # TypeScript configuration
└── README.md # Project documentation
bcrypt
: Library for hashing passwordscookie-parser
: Parse cookies for incoming requestscors
: Enable Cross-Origin Resource Sharingdotenv
: Load environment variables from.env
fileexpress
: Web framework for building REST APIshttp-status
: Manage and use HTTP status codesjsonwebtoken
: Generate and verify JSON Web Tokens (JWT)lint-staged
: Run linters on staged Git filesmongoose
: MongoDB object modeling librarynodemailer
: Send emails from Node.jsshurjopay
: Payment gateway integration for ShurjoPayzod
: Schema validation library for data
npm install bcrypt cookie-parser cors dotenv express http-status jsonwebtoken lint-staged mongoose nodemailer shurjopay zod
typescript
: TypeScript compilereslint
: Linting tool for JavaScript/TypeScriptprettier
: Code formatterts-node-dev
: Development server for TypeScript
npm install --save-dev @eslint/js @types/bcrypt @types/cookie-parser @types/cors @types/eslint__js @types/express @types/form-data @types/jsonwebtoken @types/node @types/nodemailer eslint globals prettier ts-node-dev typescript typescript-eslint
-Get api/car
-POST api/car
-PATCH api/car/:id
-DELETE api/car/:id
-GET api/car/:id
-POST(REGISTER) api/auth/register
-POST(LOG IN) api/auth/login
-POST(LOG OUT) api/auth/logout
-POST(CHANGE PASSWORD) api/auth/change-password
-GET(USER) api/auth/user
-GET(USER OWN) api/auth/me
-POST api/cart
-GET api/cart
-GET api/cart/:id
-DELETE api/cart/:id
-POST api/order
-POST(VERIFY) api/order/verify
-GET api/order
-GET(USER ORDER OWN) api/order/my-order
-PATCH api/order/:id/status
-GET(REVENUE) api/oder/revenue
-POST api/review
-GET api/review
-GET(PRODUCT BASED) api/review/:id
{
"name": "Your Name",
"email": "[email protected]",
"password": "yourpassword",
"phone": "+11111111111",
"address": "123 Main Street",
"city": "New York"
}
{
"brand": "Honda 250",
"carName": "Honda Civic 250",
"image": "https://i.ibb.co.com/R7WwqxM/pexels-photo-116675.jpg",
"model": "2024",
"year": 2024,
"price": 35000,
"category": "Sedan",
"description": "The Honda Civic 2022 is a compact sedan with a modern design. Known for its fuel efficiency, excellent handling, and advanced technology, the Civic is perfect for those who need a reliable and stylish vehicle. With its sleek looks and comfortable interior, the Civic is ideal for daily driving, offering great fuel economy of 32 MPG in the city and 42 MPG on the highway.",
"quantity": 10,
"milage": "32 MPG",
"fuelType": "Petrol",
"inStock": true
}
{
"cars": [
{
"car": "6795c98c02786d93f1084842",
"quantity": 1
}
]
}