Skip to content

david-a-perez/GitGuessr-website

Repository files navigation

Getting Started with Create Rust App

This project was bootstrapped with Create Rust App.

Requirements

  • stable Rust
  • Diesel CLI
    • if using postgres, cargo install diesel_cli --no-default-features --features postgres
    • if using sqlite, cargo install diesel_cli --no-default-features --features sqlite-bundled
  • cargo-watch to recompile on change:
    • cargo install cargo-watch (allows running cargo watch -x run -i frontend/ for continuous compilation; see "available scripts")

Notes

  • In development, the .env file is read (use .env.example for reference)
  • In production, environment variables are sourced directly

Available Scripts

In the project directory, you can run:

cargo fullstack

Runs the app in development mode and watches for changes. Visit http://localhost:3000 to view it.

Any frontend changes should instantly appear. Backend changes will need to recompile. Needs cargo-watch installed, see requirements.

To test/debug issues with the production build, set the debug-assertions to true for [profile.dev] in Cargo.toml. This way, development-only code paths are discarded and instead, production-only code paths are included.

Alternatively, use cargo run to run the app in development mode without watching for file changes.

cargo build

Builds a production-ready build.

cargo tsync

Generates the typescript types from rust code marked with tsync. Outputs to frontend/src/types/rust.d.ts.

Running frontend and backend individually

# frontend
cd frontend && npm && npm start
# backend
cargo watch -x run -i frontend/

Database Migrations

  • diesel migration generate <migration_name>

  • diesel migration run

  • diesel migration revert

  • diesel database setup

  • diesel database reset

Tips

  • Use the mold linker for slightly faster compilation.

Containerize your application

Building a container

docker build -t image-name .

Running the container

docker run -e SECRET_KEY=123 -e DATABASE_URL=postgres://postgres:postgres@localhost/database -p 3000:3000 image-name

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published