https://github.com/amithasanamithasan/carstore
Backend API Development for Car-Store
https://github.com/amithasanamithasan/carstore
apidevelopment expressjs javascript mongodb mongoose nodejs postman typescript validation
Last synced: 29 days ago
JSON representation
Backend API Development for Car-Store
- Host: GitHub
- URL: https://github.com/amithasanamithasan/carstore
- Owner: amithasanamithasan
- Created: 2024-11-24T10:04:11.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-12-19T13:47:31.000Z (4 months ago)
- Last Synced: 2025-02-10T01:41:50.989Z (3 months ago)
- Topics: apidevelopment, expressjs, javascript, mongodb, mongoose, nodejs, postman, typescript, validation
- Language: TypeScript
- Homepage: https://car-store-tau-seven.vercel.app/
- Size: 55.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Car Store B4A2V3
## Objective
Develop an Express application with TypeScript, integrating MongoDB with Mongoose to manage a Car Store. Ensure data integrity using Mongoose schema validation.---
Project Setup:
Create an Express project with TypeScript.
Set up a MongoDB database to store Cars and Orders.
Use Mongoose for schema definition and data operations.
Implement CRUD operations for both cars and orders.
## Project Setup
1. **Create an Express project with TypeScript**
- Set up the project using TypeScript for type safety.2. **Set up a MongoDB database**
- Store data for Cars and Orders.3. **Use Mongoose for schema definition and data operations**
- Define schemas for `Cars` and `Orders`.4. **Implement CRUD operations for Cars and Orders**
- Create RESTful APIs for managing Cars and Orders.---
## Models
### Car Model
- **Fields**:
- `brand` (string): Manufacturer (e.g., Toyota, BMW).
- `model` (string): Model of the car (e.g., Camry, Focus).
- `year` (number): Year of manufacture.
- `price` (number): Price of the car.
- `category` (string): Enum - `Sedan`, `SUV`, `Truck`, `Coupe`, `Convertible`.
- `description` (string): Features description.
- `quantity` (number): Available quantity.
- `inStock` (boolean): Stock status.### Order Model
- **Fields**:
- `email` (string): Customer email.
- `car` (ObjectId): Car ID (reference).
- `quantity` (number): Quantity ordered.
- `totalPrice` (number): Calculated as car price * quantity.---
## API Endpoints
### 1. Create a Car
- **Endpoint**: `/api/cars`
- **Method**: `POST`
- **Request Body**:
```json
{
"brand": "Toyota",
"model": "Camry",
"year": 2024,
"price": 25000,
"category": "Sedan",
"description": "A reliable family sedan with modern features.",
"quantity": 50,
"inStock": true
}