GithubHelp home page GithubHelp logo

movie-reservation-api's Introduction

movie-reservation-api

Objective:

Build a simple RESTful API using Node.js, Express.js, and MongoDB to manage a movie reservation system.

Requirements:

  • Movie Listing Endpoint An API endpoint to retrieve a list of available movies. Each movie should have a title and a list of available time slots with their capacities.

  • Check Availability Endpoint An API endpoint to check the availability of a specific time slot for a movie. The endpoint should take the movie ID and time slot ID as parameters and return the availability (remaining capacity) for that time slot.

  • Reserve Time Slot Endpoint An API endpoint to reserve a time slot for a movie. The endpoint should take the movie ID, time slot ID, and the number of people to reserve for.

  • Ensure that the reservation does not exceed the available capacity of the time slot.

  • Update the booked count for the reserved time slot.

Before Starting

  • Install Node js
  • Install the MongoDB community edition or open an account in MongoDB Atlas > create a free tier db and get the connection string
  • install dependencies, go to the root folder, and type
npm install 
  • Create a .env file at the root directory and add the URI to your mongo db instance
DB_URI = 

Getting Started

Run the server with npm run start

You will see the following in the console:

::: server started on port 8000 :::
::: Connected to the database successfully :::

| for ease of use, I made a seed function that will drop the collection and instantiate new Data each time the server starts

Usage

List All Movies

curl --location 'localhost:8000/v1/movies/'

Check Availability

Get the movie id and time slot id from the List All Movies endpoint

curl --location 'localhost:8000/v1/movies/<movie id>/timeslots/<time slot id>/availability'

Reserve Time Slot

Get the movie id and time slot id from the List All Movies endpoint

curl --location --request PUT 'localhost:8000/v1/movies/<movie id>/timeslots/<time slot id>/reserve' \
--header 'Content-Type: application/json' \
--data '{
    "numberOfPeople": 10
}'

Testing

npm run test

movie-reservation-api's People

Contributors

aalrayes avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.