This project is a RESTful API for managing parking lots, including parking, unparking, and ticket generation. It is built using Node.js and Express.
- Vehicle entry and parking lot initialization
- Vehicle exit and slot management
- Ticket generation and retrieval
- Parking slot status updates
- Query parked cars by size
To install and run this project locally:
- Clone this repository:
git clone https://github.com/daulatojha17/Parking-Lot-API.git
- Install the dependencies:
npm install
- Start the server:
npm run dev
-
Create a Parking Lot
- API:
/parking
- Method: POST
- Description: Creates a new parking lot with the specified floor number, parking lot name, and number of slots. Slots can be of various sizes (e.g., small, medium, large, extra-large).
- Limitation: The API currently doesn't optimize space allocation (e.g., using a medium slot for one or two small vehicles).
- API:
-
Get Parking Lot Status
- API:
/parking/status
- Method: GET
- Description: Retrieves data for all floors and their parking slots from the database.
- API:
-
Park a Car
- API:
/car/park
- Method: POST
- Description: Asks for the floor, size, and license plate number of a car. It then retrieves the nearest available parking slot and creates a ticket for that car.
- API:
-
Unpark a Car
- API:
/car/leave
- Method: POST
- Description: Takes the ticket ID from the user, frees up the corresponding parking slot, and marks the ticket as exited.
- API:
-
Get License Plates by Car Size
- API:
/ticket
- Method: GET
- Description: Takes the car size as a query parameter and returns the license plates of parked cars of that size.
- API:
-
Get Allocated Cars by Size
- API:
/parking/allocated
- Method: GET
- Description: Returns the license plates of cars of a given size that are currently allocated in the parking lot.
- API: