Skip to content

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

16 Commits

Folders and files

Repository files navigation

Ticket Fusion Server

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.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/ticket-fusion-server.git
    cd ticket-fusion-server
  2. Install dependencies:

    npm install
  3. Create a .env file 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
  4. Start the server:

    npm start

Configuration

Ensure you have a MongoDB database and a Stripe account. Configure the connection string and API keys in your .env file.

API Endpoints

Comments

  • 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.
  • Get Comments

    • GET /comments
    • Response: JSON array of comments.

Events

  • 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.
  • Get Events

    • GET /events
    • Response: JSON array of events.
  • Get Event by ID

    • GET /events/:id
    • Response: JSON of the specific event.
  • 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.
  • Delete Event

    • DELETE /events/:id
    • Headers:
      {
        "Authorization": "Bearer <token>"
      }
    • Response: JSON with the deletion result.

Seat Booking

  • 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.
  • Get Seat Bookings

    • GET /sitBook
    • Response: JSON array of seat bookings.
  • Get Seat Booking by ID

    • GET /singleSitBook/:id
    • Response: JSON of the specific seat booking.
  • Delete Seat Booking

    • DELETE /sitBook/:id
    • Headers:
      {
        "Authorization": "Bearer <token>"
      }
    • Response: JSON with the deletion result.
  • Get Seat Booking by Event ID and Email

    • GET /sitBook/:eventId/:email
    • Response: JSON of the specific seat booking.
  • Update Seat Booking

    • PATCH /sitBook/:id
    • Request Body:
      {
        "ticketNumber": "updated_ticket_number",
        "price": "updated_price"
      }
    • Response: JSON with the updated booking.

Users

  • Create User

    • POST /users
    • Request Body:
      {
        "name": "User Name",
        "email": "user_email",
        "password": "user_password"
      }
    • Response: JSON with the creation result and token.
  • Get Users

    • GET /users
    • Response: JSON array of users.
  • Get User by Email

    • GET /users/:email
    • Response: JSON of the specific user.
  • 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.

Payments

  • Create Payment Intent

    • POST /create-payment-intent
    • Request Body:
      {
        "price": "total_price"
      }
    • Headers:
      {
        "Authorization": "Bearer <token>"
      }
    • Response: JSON with the client secret.
  • 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.
  • Get Payment History

    • GET /paymentHistory/:email
    • Response: JSON array of payments.

Authentication

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.

Permissions Policy

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();
});

Contributing

Feel free to submit issues or pull requests. For major changes, please open an issue first to discuss what you would like to change.

License

MIT


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.

About

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages