Skip to content

Latest commit

 

History

History
166 lines (125 loc) · 2.46 KB

getting-started.md

File metadata and controls

166 lines (125 loc) · 2.46 KB

Getting Started with the API

Usage

  1. Download the code and cd into the directory:
    $ git clone [email protected]:alvyynm/ticketbookingsystem.git
    $ cd ticketbookingsystem
  2. Install necessary libraries and dependencies
    $ cd src && npm install
  3. Navigate to the src directory and start server.
    $ cd src
    $ npm run dev
    Server runs on port 4000 (by default).

API Reference

Routes

Authentication Routes

POST /v1/auth/signup

payload:
{
  "name": "Name ",
  "email": "[email protected]",
  "role": "admin" || "user",
  "password": "password@123P"
}

POST /v1/auth/login

payload:
{
  "email": "[email protected]",
  "password": "password@123P"
}

POST /v1/auth/logout

  • Logout
headers:
Authorization: `Bearer ${token}`

Event Routes

GET /v1/events

  • Get all events from the database

POST /v1/events

  • Create a new event
  • admin role required
headers:
Authorization: `Bearer ${token}`
payload:
{
  "event_name": "Name of event",
  "event_description": "description of the event",
  "start_date": "2024-03-26T04:10:00.000Z",
  "end_date": "2024-03-29T04:14:00.000Z",
  "max_attendees": "3",
  "ticket_price_vip": "480",
  "ticket_price_regular": "130"
}

GET /v1/events/:event_id

  • Get details about a single event

PUT /v1/events/:event_id

  • Update a single event
  • admin role required
headers:
Authorization: `Bearer ${token}`
payload:
{
  "event_name": "Name of event",
  "event_description": "description of the event",
  "start_date": "2024-03-26T04:10:00.000Z",
  "end_date": "2024-03-29T04:14:00.000Z",
  "max_attendees": "3",
  "available_seats": "1",
  "ticket_price_vip": "480",
  "ticket_price_regular": "130"
}

DELETE /v1/events/:event_id

  • Delete an event
  • admin role required
headers:
Authorization: `Bearer ${token}`

Ticket Routes

POST /v1/tickets

  • Create a ticket
payload:
{
  "event_id": 9,
  "seats_reserved": {min: 1, max: 5},
  "ticket_type": "regular" || "vip",
  "ticket_price": 500
}

GET /v1/tickets

  • Get tickets created by logged in user
  • Must be authenticated
headers:
Authorization: `Bearer ${token}`

GET /v1/tickets/:event_id

  • Get details about a ticket
  • Must be admin user and authenticated

POST /v1/tickets/verify

  • Verify a ticket's serial number
payload:
{
  "ticket_serial": "your ticket serial"
}