Giter VIP home page Giter VIP logo

realworld-rust-axum's Introduction

Realworld Rust

Realworld Rust Axum Prisma

This project utilizes Rust with the Axum v0.7 framework along with the Prisma Client Rust to build a realworld application. For Prisma Client Rust ORM, refer to Prisma and Prisma Client Rust Repository for more information.

Prerequisites

Make sure you have the following installed:

  • Rust
  • Docker
  • MySQL

Getting Started

Installation

  1. Clone this repository.
  2. Set up your environment variables by creating a .env file in the root directory. Use the provided examples in the README as a guide.
  3. Ensure your MySQL server is running.
  4. Apply migrations
  5. Generate Prisma Client

If you want to use other databases, you need to change the database URL in the .env file and change database provider in schema.prisma file. For more information check out Docs.

Running the Application

You can use the provided justfile for various commands:

  • just setup: Apply migrations using prisma-cli.
  • just generate: Generate the Prisma Client using prisma-cli.
  • just run: Run the application using cargo run.
  • just watch: Use cargo watch to automatically reload the application on file changes.
  • just build: Build the application using the development profile.
  • just release: Build the application for release.
  • just test: Run tests using cargo test.

Docker Setup

If you prefer Docker, follow these steps:

  1. Build the Docker image:

    The Dockerfile includes steps to build the project within a Docker container. Particularly, the cargo prisma generate command is used to generate the Prisma Client during the Docker image build process. This command parses the Prisma schema and creates a client tailored to the defined database structure.

    docker-compose build
  2. Start the containers:

    docker-compose up

Environment Variables

Ensure your environment variables are appropriately set. Here are some examples:

  • DATABASE_URL: MySQL database URL.
  • PORT: Port on which the application runs.
  • RUST_LOG: Rust logging level.
  • JWT_SECRET: Secret key for JWT authentication.
  • MYSQL_ROOT_PASSWORD: If using docker-compose make sure to set MySQL root password.

⚠️ Important Note

This project cannot be built in release mode using Rust stable toolchain version 1.7.4 (stable-aarch64-apple-darwin) due to a compilation error with the psl-core library. However, it can be successfully built in debug mode using this toolchain.

Contributing

Contributions are welcome! Feel free to open issues or pull requests.

License

This project is licensed under the MIT License.

realworld-rust-axum's People

Contributors

chojs23 avatar aoipril avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.