Skip to content

kobbi1/vef-2025-h1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hopverkefni 1

We decided to make a movie rental service, where USER role can rent movies, and the ADMIN role can add movies

Team

Jakob Daníel Vigfússon

Omar Altabbaa

Installation

npm install --force

Usage

For now, you need to use something like postman to interact. since no frontend has been created, since we were told that we would be using react for frontend for Hopverkefni 2

Authentication for user

Admin Account Login Information:

POST request: http://localhost:5050/auth/login
{
  "email": "admin@admin.com",
  "password": "hopverkefni1"
}

Register:

POST request: http://localhost:5050/auth/register
{
  "email": "test@example.com",
  "password": "password123"
}

Login:

POST request: http://localhost:5050/auth/login
{
  "email": "test@example.com",
  "password": "password123"
}

Renting a movie

Create a Rental:

POST request: http://localhost:5050/rentals
{
  
  "userId": 1,
  "movieId": 2

}

Get All Rentals:

GET request: http://localhost:5050/rentals

Get Rentals by User:

GET request: http://localhost:5050/rentals/user/1

Return a Movie:

PUT request: http://localhost:5050/rentals/1/return

Delete a Rental:

DELETE request: http://localhost:5050/rentals/1

Adding, Updating and Deleting movies

Add Movie

POST request: http://localhost:5050/movies
Must use admin login and get token, go to authorization and select Bearer Token
Go to body and use form data

Key             |   Type   | Value
============================================================================
title           |   Text   | The Shawshank Redemption
description     |   Text   | A banker convicted of...
releaseYear     |   Text   | 1994
poster          |   File   | Upload this from your PC (MUST BE JPEG OR PNG)
rentalPrice     |   Text   | 1000
availableCopies |   Text   | 10

Delete Movie

Must use admin login and get token, go to authorization and select Bearer Token

DELETE request: http://localhost:5050/movies/5

Update Movie

Must use admin login and get token, go to authorization and select Bearer Token

PUT request: http://localhost:5050/movies/1

{
    "description": "Very cool very nice, works yes yes"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •