Ticket Fusion is a server application for managing events, users, comments, seat bookings, and payments. This project is built using Node.js, Express, MongoDB, and integrates with Stripe for payment processing.
-
Clone the repository:
git clone https://github.com/yourusername/ticket-fusion-server.git cd ticket-fusion-server -
Install dependencies:
npm install
-
Create a
.envfile in the root directory and add the following environment variables:PORT=your_port_number DB_URI=your_mongodb_uri PAYMENT_SECRET_KEY=your_stripe_secret_key
-
Start the server:
npm start
Ensure you have a MongoDB database and a Stripe account. Configure the connection string and API keys in your .env file.
-
Create Comment
- POST
/comments - Request Body:
{ "eventId": "event_id", "comment": "Your comment", "email": "user_email" } - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the inserted comment.
- POST
-
Get Comments
- GET
/comments - Response: JSON array of comments.
- GET
-
Create Event
- POST
/events - Request Body:
{ "title": "Event Title", "description": "Event Description", "date": "Event Date", "price": "Event Price" } - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the inserted event.
- POST
-
Get Events
- GET
/events - Response: JSON array of events.
- GET
-
Get Event by ID
- GET
/events/:id - Response: JSON of the specific event.
- GET
-
Update Event
- PATCH
/events/:id - Request Body:
{ "title": "Updated Event Title", "description": "Updated Event Description", "date": "Updated Event Date", "price": "Updated Event Price" } - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the updated event.
- PATCH
-
Delete Event
- DELETE
/events/:id - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the deletion result.
- DELETE
-
Book Seat
- POST
/sitBook - Request Body:
{ "eventId": "event_id", "email": "user_email", "ticketNumber": "number_of_tickets", "price": "total_price" } - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the booking result.
- POST
-
Get Seat Bookings
- GET
/sitBook - Response: JSON array of seat bookings.
- GET
-
Get Seat Booking by ID
- GET
/singleSitBook/:id - Response: JSON of the specific seat booking.
- GET
-
Delete Seat Booking
- DELETE
/sitBook/:id - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the deletion result.
- DELETE
-
Get Seat Booking by Event ID and Email
- GET
/sitBook/:eventId/:email - Response: JSON of the specific seat booking.
- GET
-
Update Seat Booking
- PATCH
/sitBook/:id - Request Body:
{ "ticketNumber": "updated_ticket_number", "price": "updated_price" } - Response: JSON with the updated booking.
- PATCH
-
Create User
- POST
/users - Request Body:
{ "name": "User Name", "email": "user_email", "password": "user_password" } - Response: JSON with the creation result and token.
- POST
-
Get Users
- GET
/users - Response: JSON array of users.
- GET
-
Get User by Email
- GET
/users/:email - Response: JSON of the specific user.
- GET
-
Update User
- PATCH
/users/:email - Request Body:
{ "name": "Updated User Name", "password": "Updated User Password" } - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the updated user.
- PATCH
-
Create Payment Intent
- POST
/create-payment-intent - Request Body:
{ "price": "total_price" } - Headers:
{ "Authorization": "Bearer <token>" } - Response: JSON with the client secret.
- POST
-
Submit Payment
- POST
/payments - Request Body:
{ "email": "user_email", "eventId": "event_id", "price": "total_price", "paymentIntentId": "payment_intent_id" } - Response: JSON with the payment result and deletion result.
- POST
-
Get Payment History
- GET
/paymentHistory/:email - Response: JSON array of payments.
- GET
The application uses JWT for authentication. To create a token, the server generates a JWT token upon user registration or login. This token is required for protected routes.
The server sets a Permissions-Policy header to disable the interest-cohort feature:
app.use((req, res, next) => {
res.setHeader('Permissions-Policy', "interest-cohort=()");
next();
});Feel free to submit issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.
This `README.md` provides a comprehensive guide to your server application, including setup, configuration, API endpoints, authentication, and additional information relevant to developers using or contributing to your project.