8000 GitHub - jaswiate/rental
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

jaswiate/rental

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Library

Web application for managing and using an online library service - a project for the Databases course at AGH UST.

Authors:

  • Marcin Ĺ»urawel
  • Kuba ĹšwiÄ…tek

Key features:

  • browsing and renting resources from the library
  • admin panel for managing rentals and pending shipment requests

Technologies:

  • Frontend: TypeScript, React, Chakra UI
  • Backend: TypeScript, Express, JWT, bcrypt.js, Mongoose.js
  • Database: MongoDB, MongoDB Atlas

Database Schema:

We used a NoSQL database, so our schema took form of 3 MongoDB collections:

Rental

{
    _id: string,
    clientId: User_id,
    productId: Product_id,
    productName: string,
    quantity: number,
    isPending: boolean,
    address: { street: string, zipCode: string, city: string },
    borrowDate?: Date,
    dueDate?: Date,
    returnDate?: Date,
    fine?: number,
    ifProlonged?: boolean,
}

User

{
    _id: string,
    username: string,
    password: string,
    role: "admin" | "user",
}

Product

{
    _id: string,
    name: string,
    description?: string,
    quantity: number,
    imageUrl?: string,
}

API endpoints

Rentals

GET /rentals/fines

Get fines information.

Parameters

None

Privilages
  • Admin
Responses
HTTP Status Content-Type Response Body
200 application/json Array of fine objects
401 application/json { "message": "Unauthorized!" }
403 application/json { "message": "No token provided!" }
403 application/json { "message": "Unauthorized: no admin privileges" }
GET /rentals/pending

Retrieve pending rentals.

Parameters

None

Privilages
  • Admin
Responses
HTTP Status Content-Type Response Body
200 application/json Array of rental objects
401 application/json { "message": "Unauthorized!" }
403 application/json { "message": "No token provided!" }
403 application/json { "message": "Unauthorized: no admin privileges" }
GET /rentals

Retrieve all rentals.

Parameters

None

Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Array of rental objects
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Rental not found." }
GET /rentals/:id

Retrieve a rental by ID.

Parameters
Name Type Description
id String ID of the rental
Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Rental object
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Rental not found." }
POST /rentals

Add a new rental.

Parameters
Name Type Description
userId String ID of the user renting
productId String ID of the product being rented
rentalDate String Date of rental
returnDate String Date of return
Privilages
  • User
Responses
HTTP Status Content-Type Response Body
201 application/json Created rental object
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
400 application/json { "error": "Insufficient quantity available for the product." }
404 application/json { "error": "Product not found." }
PUT /rentals/:id

Update a rental by ID.

Parameters
Name Type Description
id String ID of the rental
userId String Updated ID of the user renting
productId String Updated ID of the product being rented
rentalDate String Updated date of rental
returnDate String Updated date of return
Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Updated rental object
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Rental not found." }
DELETE /rentals/:id

Delete a rental by ID.

Parameters
Name Type Description
id String ID of the rental
Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Success message
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Rental not found." }

User

POST /user/signup

User Registration

Parameters
Name Type Description
username String User's username
password String User's password
Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Object of the registered user
POST /user/signin

User Login

Parameters
Name Type Description
username String User's username
password String User's password
Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Object of the logged-in user
GET /user/rentals

Get User Rentals

Parameters

None

Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Array of user's rental objects
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }

Products

GET /products

Retrieve all products.

Parameters

None

Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Array of product objects
404 application/json { "error": "Product not found." }
POST /products

Add a new product.

Parameters
Name Type Description
name String Name of the product
description String Description of the product
quantity Number Quantity of the product
imageUrl String URL of the product image
Privilages
  • Admin
Responses
HTTP Status Content-Type Response Body
201 application/json Created product object
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Product not found." }
GET /products/:id

Retrieve a product by ID.

Parameters
Name Type Description
id String ID of the product
Privilages
  • User
Responses
HTTP Status Content-Type Response Body
200 application/json Product object
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Product not found." }
PUT /products/:id

Update a product by ID.

Parameters
Name Type Description
id String ID of the product
name String Updated name of the product
description String Updated description of the product
quantity Number Updated quantity of the product
imageUrl String Updated URL of the product image
Privilages
  • Admin
Responses
HTTP Status Content-Type Response Body
200 application/json Updated product object
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Product not found." }
DELETE /products/:id

Delete a product by ID.

Parameters
Name Type Description
id String ID of the product
Privilages
  • Admin
Responses
HTTP Status Content-Type Response Body
200 application/json Success message
403 application/json { "message": "No token provided!" }
401 application/json { "message": "Unauthorized!" }
404 application/json { "error": "Product not found." }

Tour

After opening the app we are redirected to the authorization page.
image
Successful sign up results in a new record being created in the database. We can also see the password being properly hashed.
image
After logging in, a personal homepage is being displayed, where we can view our current rentals.
image
We just created our account, so no rentals are being shown. Let's head to the Collection page and make our first rental! We're true fantasy connoisseurs, so we pick J.R.R. Tolkien's Silmarillion.
image
We can then specify the quantity.
image
Finally we can see our rental is succesfully displayed on the homepage.
image
If we log in as an admin, we can view a special panel displaying incoming orders, and enabling us to confirm successful shipments.
image

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 96.8%
  • HTML 2.5%
  • CSS 0.7%
0