Skip to content

9m-pwn/reservations

Repository files navigation

Reservations API

This is a simple Reservation API built with NestJS. It allows for

  • initializing tables
  • reserving tables for customers
  • canceling reservations
  • retrieving all reservations.
  • reset tables

Prerequisites

  • Node.js (version 18 or higher)
  • Docker (if you want to run the project using Docker)

1. Installation

$ npm install

2. Running the app

There are 2 options for running application

2.1 with docker

$ docker compose up --build

2.2 without docker

$ npm start

After startup is done, the application will be available at http://localhost:3000/api.




API Endpoints

  1. Initialize Tables

  • URL: /reservations/initialize
  • Method: POST
  • Query Parameters:
    • totalTables (number): The total number of tables to initialize.
  • Responses:
    • 201 Created: Tables have been initialized.
    • 400 Bad Request: Invalid parameters or tables already initialized.


  1. Reserve Tables

  • URL: /reservations/reserve
  • Method: POST
  • Query Parameters:
    • customers (number): The number of customers to reserve tables for.
  • Responses:
    • 200 OK: Tables have been reserved.
    • 400 Bad Request: Invalid parameters or not enough tables available.


  1. Cancel Reservation

  • URL: /reservations/cancel
  • Method: POST
  • Query Parameters:
    • bookingId (string): The ID of the booking to cancel.
  • Responses:
    • 200 OK: Reservation has been cancelled.
    • 404 Not Found: Booking ID not found.


  1. Get All Reservations

  • URL: /reservations/all-reservations
  • Method: GET
  • Responses:
    • 200 OK: Returns all reservations.
    • 404 Not Found: No reservations found.


  1. Reset tables

  • URL: /reservations/reset
  • Method: POST
  • Responses:
    • 205 OK: Returns null



Testing

There are unit test and integration test, you can use the command below for testing

Unit test

$ npm run test:unit

Integration test

$ npm run test:e2e



About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published