This RESTful API allows administrators to manage train bookings. It handles stations, trains, users, and bookings, enabling functionalities like creating trains with routes, booking seats, and user management.
MIT License
Welcome to the Train Ticket Booking System. This application allows administrators to manage users, stations, trains, and bookings through a RESTful API.
Clone the repository:
git clone https://github.com/venkateshramkumarg/ecommerce_backend.git
cd TrainTicket
Install dependencies:
npm install
Set up the database using Prisma:
npx prisma migrate dev
Start the application:
npm start
The application runs on http://localhost:3000/api
. You can use tools like Postman or curl to interact with the API.
Create Admin
POST /api/admin/create/admin/new
Request Body:
{
"user_name": "admin_name",
"password": "password",
"email": "[email protected]"
}
Delete Admin
DELETE /api/admin/delete/admin/:name
Update Admin
PUT /api/admin/update/admin/:name
Request Body:
{
"password": "new_password",
"email": "[email protected]"
}
Create Station
POST /api/stations/create/station/new
Request Body:
{
"user_name": "admin_name",
"stationId": "station_id",
"stationName": "station_name"
}
Delete Station
DELETE /api/stations/delete/station/:id
Get Station by ID
GET /api/stations/stations/:id
Create Train
POST /api/trains/create/train/new
Request Body:
{
"user_name": "admin_name",
"trainNo": "train_number",
"trainName": "train_name",
"noOfSeatsAvailable": "number_of_seats",
"departureDate": "departure_date",
"stationIds": ["station_id1", "station_id2"]
}
Delete Train
DELETE /api/trains/delete/train/:number
Create User
POST /api/users/create/user/new
Request Body:
{
"user_name": "user_name",
"password": "password",
"email": "[email protected]"
}
Delete User
DELETE /api/users/delete/user/:name
Update User
PUT /api/users/update/user/:name
Request Body:
{
"password": "new_password",
"email": "[email protected]"
}
Create Booking
POST /api/bookings/create/booking/new
Request Body:
{
"user_name": "user_name",
"trainNo": "train_number",
"seatNo": "seat_number"
}
Delete Booking
DELETE /api/bookings/delete/booking/:id
Create a .env
file in the root directory and add the following environment variables: