DarkMaper / todo-app-rust-crud-api

Todo App using Rust for backend

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TODO App Backend

License: MIT

App written in Rust using Rocket for API server and Diesel MySQL.


Todo list

  • Connection to Database
  • Create Signin and Signup routes and controllers
    • Refresh Token System
  • Add auth guard for JWT
  • Notes
    • Show notes from logged user
    • Create notes
    • Edit notes
    • Delete notes

Usage

Building app

Note: For Windows, you need install MySQL Connector C (included in MySQL Server) and set environment variable MYSQLCLIENT_LIB_DIR to the path of the folder containing the mysqlclient.dll file. For Linux, you need libmysqlclient-dev in Debian-based distros.

cargo build --release

Docker

You can build a image of the app with:

docker build -t todoapp .

And run a container with:

docker run -p 3000:3000 \
-e ROCKET_DATABASES={todoapp={url="mysql://user:password@database_host/database_name"}} \
-e ROCKET_PORT=3000 \
-e ROCKET_ADDRESS=0.0.0.0 \
-e ALLOWED_ORIGINS=http://localhost,http://localhost:8080 \
--name todoapp-container todoapp

Docker Compose

version: '3.9'
services:
  app:
    build: .
    restart: always
    environment:
      - ROCKET_DATABASES={todoapp={url="mysql://todoapp:todoapp@db/todoapp"}}
      - ROCKET_PORT=3000
      - ROCKET_ADDRESS=0.0.0.0
      - ALLOWED_ORIGINS=http://localhost,http://localhost:8080
    depends_on:
      - db
    ports:
      - "3000:3000"
  db:
    image: mariadb:10.7.4
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=root
      - MYSQL_DATABASE=todoapp
      - MYSQL_USER=todoapp
      - MYSQL_PASSWORD=todoapp
    volumes:
      - todoapp-db:/var/lib/mysql
volumes:
  todoapp-db:

MIT License

About

Todo App using Rust for backend

License:MIT License


Languages

Language:Rust 97.9%Language:Dockerfile 2.1%