Skip to content

A simple REST API application, implemented in rust programming language. The four API's (GET, POST, PUT, DELETE) are implemented. PostgreSQL is used as database.

License

Notifications You must be signed in to change notification settings

GaneshJadhavOnGitHub/REST-RUST-POSTGRESQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

REST-RUST-POSTGRESQL

A simple REST API application, implemented in rust programming language. The four API's (GET, POST, PUT, DELETE) are implemented. PostgreSQL is used as database.

Application takes information for a movie and calculates Verdict of that Movie.

Features :-

  1. Input and Business Validations are done.
  2. Error Handling is done.
  3. Rolling JSON logs are provided.

⚠️ Important Note on CORS (Cross-Origin Resource Sharing)

CORS (Cross-Origin Resource Sharing) is an HTTP protocol mechanism that allows servers to specify which origins (domains, schemes, or ports) are permitted to access resources on the server. It is primarily used to enable secure cross-origin requests, such as when a web application on one domain requests resources hosted on another domain.

This REST API currently does not have CORS (Cross-Origin Resource Sharing) functionality implemented.

Please refer HELP folder for any kind of help.


To Run application.

A> Refer HELP\Application_Requirements.txt for system requirements.

B> Clone the repository.

C> Install PostgreSQL , Create Database and Table

Download installer from following website
https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

     1. Downloaded PostgreSQL Version 15.2 for Windows x86-64.
        Set up file is stored at I:\RequiredSoftwares\Softwares\PostgreSQL

     2. Refer following URL for installation.
        https://www.sqlshack.com/how-to-install-postgresql-on-windows/

     3. Right clock on set up exe 'postgresql-15.2-1-windows-x64' and run as admin.

     4. Specify installation directory as 'F:\Program Files\PostgreSQL\15'

     5. Select All components and click next.

     6. Select Data Directory where we want to store data.
        
     7. Provide password for database superuser (postgres)
        user - postgres
        password - postgres

     8. Provide Port Number as 5432.

     9. In Advanced Options select Locale as Default Locale.

     10. Take screenshot of PreInstallation Summary and click next. 
         This screenshot is present in HELP\SQL_Scripts folder.



     Refer HELP\SQL_Scripts folder to create database.
     Refer same folder for SQL queries. 

D> In VS Code Open Thunder Client, select Collections. Click Menu at the right side and select Import. Import JSON requests collection. This collection is present in file HELP\thunder-collection_REST_PostgreSQL_Movies_Collection.json.

E> Build and Run

cargo build

cargo run

Send requests from Thunder Client.


Output :-

  1. APPLICATION STARTED

Application_Started

  1. POST

CREATE_MOVIE

  1. GET

READ_MOVIES

  1. PUT

UPDATE_MOVIE

  1. DELETE

DELETE_MOVIE


Repository Tree Structure

├── HELP
    ├── Application_Requirements.txt
    ├── SQL_Scripts
    │   ├── CreateDatabase.txt
    │   ├── CreateTable.sql
    │   ├── DeleteRow.sql
    │   ├── InsertRow.sql
    │   ├── InstallationSummary.png
    │   ├── SearchByMovieId.sql
    │   ├── SelectRows.sql
    │   ├── UpdateQuery.sql
    │   ├── movies_backup
    │   ├── movies_backup.sql
    │   └── movies_dump
    └── thunder-collection_REST_PostgreSQL_Movies_Collection.json
├── LICENSE
├── OUTPUT_SCREENSHOTS
    ├── Application_Started.png
    ├── CREATE_MOVIE.png
    ├── DELETE_MOVIE.png
    ├── READ_MOVIES.png
    └── UPDATE_MOVIE.png
├── README.md
└── rest_rust_postgres
    ├── .gitignore
    ├── .vscode
        └── settings.json
    ├── Cargo.lock
    ├── Cargo.toml
    ├── boxoffice_json_log_configuration.yaml
    ├── log
        └── boxoffice_json_log.log
    └── src
        ├── business_layer.rs
        ├── constants.rs
        ├── db_layer.rs
        ├── error.rs
        ├── handler.rs
        ├── main.rs
        ├── model.rs
        ├── request_response_structs.rs
        ├── response.rs
        └── routes.rs