/rust-todo-app

This is a simple todo API built with Rust and Actix-Web. It uses MySQL database to store the todos.

Primary LanguageRustMIT LicenseMIT

Rust Todo API with Actix-Web

Description

This is a simple todo API built with Rust and Actix-Web. It uses MySQL database to store the todos.

Features

  • Authentication

    • Register
    • Login
    • Refresh token
    • Logout
    • (The API uses JWT for authentication.)
  • Todos: CRUD operations

    • Includes pagination and sorting
  • User: CRUD operations

  • Coming soon: User roles and permissions

Prerequisites

Before you begin, ensure you have met the following requirements:

  • You have installed the latest version of Rust and Cargo.

Installing

To install , follow these steps:

  1. Clone the repository:
git clone https://github.com/chornthorn/rust-todo-app.git
  1. Navigate to the project directory:
cd rust-todo-app

Setting Up the Database

Before running the application, you need to set up the database. This project uses sqlx, which supports multiple database systems. The instructions below are for MySQL.

  1. Install MySQL if you haven't already. You can download it from here.

  2. Create a new MySQL database for the project.

  3. Copy the .env.example file to a new file named .env:

cp .env.example .env
  1. Open the .env file and set the DATABASE_URL environment variable to the connection string for your database. For example, it might look like this:
DATABASE_URL=mysql://username:password@localhost/database_name

Replace username, password, and database_name with your actual MySQL username, password, and the name of the database you created.

Running Migrations

This project uses sqlx for database migrations. To run migrations, follow these steps:

  1. Install the sqlx-cli tool if you haven't already:
brew install sqlx-cli
  1. Run the migrations:
sqlx migrate run

or using cargo:

cargo sqlx migrate run

This will apply all migrations in the migrations directory to your database.

Using

To use , follow these steps:

  1. Build the project:
cargo build --release
  1. Run the project:
cargo run

Running Tests

To run tests, use the following command:

cargo test

Contributing to Rust Todo API with Actix-Web

To contribute to Rust Todo API with Actix-Web, follow these steps:

  1. Fork this repository.
  2. Create a branch: git checkout -b <branch_name>.
  3. Make your changes and commit them: git commit -m '<commit_message>'
  4. Push to the original branch: git push origin <project_name>/<location>
  5. Create the pull request.

Contact

If you want to contact me you can reach me at thorn.c@khodedev.com.

License

This project uses the following license: MIT.