This is a simple API for managing vehicle parking in a parking lot. The API allows you to add, view, update, and delete vehicles from the parking system.
All vehicle-related operations are accessible under the /api/v1/vehicles endpoint.
/app.use("/api/v1/vehicles", vehicles);Retrieves a list of all vehicles currently parked in the parking lot.
Response:
- Status: 200 OK
- Body:
{
"allVehicles": [
{
"vehicleDetail": "ABC123",
"checkedIn": true,
"checkedInDateTime": "2025-02-10T10:00:00.000Z",
"checkedOutDateTime": null
},
{
"vehicleDetail": "XYZ456",
"checkedIn": false,
"checkedInDateTime": "2025-02-01T08:00:00.000Z",
"checkedOutDateTime": "2025-02-05T16:30:00.000Z"
}
]
}Error Response:
- Status: 500 Internal Server Error
- Body:
{
"error": "Error message"
}Adds a new vehicle to the parking lot.
Request Body:
{
"vehicleDetail": "ABC123",
"checkedIn": true,
"checkedInDateTime": "2025-02-10T10:00:00.000Z"
}Response:
- Status: 201 Created
- Body:
{
"vehicle": {
"vehicleDetail": "ABC123",
"checkedIn": true,
"checkedInDateTime": "2025-02-10T10:00:00.000Z",
"checkedOutDateTime": null
}
}Error Response:
- Status: 500 Internal Server Error
- Body:
{
"msg": "Error message"
}Retrieves details of a specific vehicle by its vehicleDetail (ID).
Response:
- Status: 200 OK
- Body:
{
"result": {
"vehicleDetail": "ABC123",
"checkedIn": true,
"checkedInDateTime": "2025-02-10T10:00:00.000Z",
"checkedOutDateTime": null
}
}Error Responses:
- Status: 404 Not Found
- Body:
{
"msg": "No records found for vehicle detail: ABC123"
}- Status: 500 Internal Server Error
- Body:
{
"error": "Error message"
}Updates details of an existing vehicle by its vehicleDetail (ID).
Request Body:
{
"checkedIn": false,
"checkedOutDateTime": "2025-02-05T16:30:00.000Z"
}Response:
- Status: 200 OK
- Body:
{
"vehicleDetail": {
"vehicleDetail": "ABC123",
"checkedIn": false,
"checkedInDateTime": "2025-02-10T10:00:00.000Z",
"checkedOutDateTime": "2025-02-05T16:30:00.000Z"
}
}Error Responses:
- Status: 404 Not Found
- Body:
{
"msg": "No records found for vehicle detail: ABC123"
}- Status: 500 Internal Server Error
- Body:
{
"msg": "Error message"
}Deletes a vehicle from the parking lot by its vehicleDetail (ID).
Response:
- Status: 200 OK
- Body:
{
"vehicleDetail": {
"vehicleDetail": "ABC123",
"checkedIn": true,
"checkedInDateTime": "2025-02-10T10:00:00.000Z",
"checkedOutDateTime": null
}
}Error Responses:
- Status: 404 Not Found
- Body:
{
"msg": "No records found for vehicle detail: ABC123"
}- Status: 500 Internal Server Error
- Body:
{
"msg": "Error message"
}-
Clone the repository:
git clone <repository-url> cd <project-folder>
-
Install dependencies:
npm install
-
Start the server:
npm start
By default, the API will be running on http://localhost:3001.
This project is licensed under the MIT License.