rocket-rust-web-server

Rocket Rust Web Server with Diesel & PostgreSQL

This project is a web server built with Rocket, using Diesel for database management and PostgreSQL as the database.

Features

Requirements

Setup

  1. Install Rust:

    Follow the instructions at Rust’s official site.

  2. Install PostgreSQL:

    Download and install PostgreSQL from PostgreSQL’s official site.

  3. Install Diesel CLI:

    Install the Diesel CLI with the following command:

    cargo install diesel_cli --no-default-features --features postgres
    
  4. Set Up PostgreSQL Database:
    • Ensure PostgreSQL is running.
    • Create a database.
      createdb rocket_server
      
    • Update your rocket.toml file with the database URL:
      [global.databases]
      postgres_db = { url = "postgres://postgres:yourpassword@localhost/rocket_server" }
      
  5. Setup Environment (Windows only workaround): If running on Windows, [follow this solution](https://github.com/diesel-rs/diesel/discussions/2947#discussioncomment-2025857.
  6. Run Migrations: Create the Diesel migrations:
    diesel migration run
    
  7. Run the Server: Run the Rocket server with:
    $env:ROCKET_LOG="debug"; cargo run # for Windows
    ROCKET_LOG=debug cargo run         # for Linux/MacOS
    
  8. Access the server: The server will be available at http://localhost:8000.

Troubleshooting

License

This project is licensed under the MIT license.