Coder Social home page Coder Social logo

m3s2peerprogramming's Introduction

Setup

Note: For this exercise, we have provided an .env file with the database connection string. Normally, you would not commit this file to version control. We are doing it here for simplicity and given that we are using a local SQLite database.

Database

This project should be used with the movies.db database in data/ folder. It is the same database that we used in the previous exercise. You can download a fresh database here or from CS50.

Migrations

We can run migrations with the following command:

npm run migrate:latest

Running the server

In development mode:

npm run dev

In production mode:

npm run start

Updating types

If you make changes to the database schema, you will need to update the types. You can do this by running the following command:

npm run generate-types

Users

  1. Get a list of users by providing their IDs
  • Endpoint: Get /movies
  • Parameters: id
  • e.g: Get /movies?id=133093,816692 should return 2 movies with these IDs
  • Constraints: Movie IDs must exists in the database
  • Data: each movie must contain Id, title, and year.
  1. Get a list of screenings available for booking
  • should return a list of existing articles
  • Endpoint: Get /screenings
  • Parameters: None
  • e.g: Get /screenings should return existing articles, if no screenings is avaliable, return an empty array
  • Data: session information (timestamp, number of tickets, number of tickets left) and movies: (title and year).
  • Suggested table:
CREATE TABLE screenings (
  id INTEGER PRIMARY KEY,
  time_stamp TIMESTAMP,
  number_of_tickets INTEGER,
  number_of_tickets_left INTEGER,
  movie_id INTEGER,
  FOREIGN KEY(movie_id) REFERENCES movies(id)
);
  1. get a list of bookings (tickets) they have booked
  • should return a list of existing tickets
  • Endpoint: Get /tickets
  • Parameters: None
  • e.g: Get /screenings should return existing tickes, if no ticket is avaliable, return an empty array
  • Data:
  1. create a booking (ticket) for movie screening
  • should create a ticket
  • Enpoint: Post /tickets
  • Data: e.g { "movie_id" = 1, number_of_tickets_purchase = 2 }

Administrators

  1. create new viewing screenings for watching a movie
  • should create a new viewing
  • Endpoint: Post /screenings
  • Data: e.g. { movie_id = 1, screening_timestamp= "some time stamp", total_tickets_allocation= 100 }

m3s2peerprogramming's People

Contributors

ufuksaylan avatar adilarslann avatar mehmettop360 avatar

Watchers

 avatar

m3s2peerprogramming's Issues

Implement Get /tickets

Get /screenings should return existing tickes, if no ticket is avaliable, return an empty array

Create a migration for the new table screenings

Implement the following table using kysely:

CREATE TABLE screenings (
id INTEGER PRIMARY KEY,
time_stamp TIMESTAMP,
number_of_tickets INTEGER,
number_of_tickets_left INTEGER,
movie_id INTEGER,
FOREIGN KEY(movie_id) REFERENCES movies(id)
);

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.