desonglll / crab_rocket

基于Rust的仓库管理系统

Home Page:https://desonglll.github.io/crab_rocket/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🦀 Crab Rocket

A web backend server written in Rust and based on Rocket.

crab_rocket

🧩 Project Dependencies

  • Rust
  • Rocket
  • Diesel
  • dotenvy
  • serde_json
  • chrono

⚙️ Requirements

  • Rust 2021 environment
  • PostgreSQL

🥰 Development

Database Migration

# Install Diesel CLI
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/diesel-rs/diesel/releases/download/v2.2.1/diesel_cli-installer.sh | sh

cd ./modules/cb_schema

# Setup Diesel
diesel setup

# Redo and run migrations
diesel migration redo
diesel migration run

# Run the server
cargo run

!!! Everytime run cargo test should run diesel database reset first.

🔧 Compile Release Version

cargo build --release

Installation

cargo install --path .

🚀 Running the Binary

Set the environment variable:

export DATABASE_URL=postgres://@localhost/hello_rocket

Alternatively, update the .env file in the project root.

Reset Database

diesel database reset

Run

crab_rocket

📖 Change Log

Change Log

(Optional) Run with Docker

docker build -t crab_rocket .
docker run --name crab_rocket_demo --rm -p 8000:8000 crab_rocket

(Optional) mise

mise run r

Configured in .mise.config.toml

Implementation Notes

  • Ensure the sequence of fields in structs matches the database schema exactly.
  • Mismatches may lead to errors in Queryable.

(Optional) Docker Toast

cargo install toast
docker build -t crab_rocket .
toast

(Optional) Docker Compose for PostgreSQL

version: "3.1"

services:
  db:
    image: postgres
    ports:
      - "5432:5432"
    restart: always
    environment:
      POSTGRES_PASSWORD: changemeinpred!

(Optional) Using posting

pip install posting
posting --collection ./posting

(Optional) Using cross

Installation

cargo install cross --git https://github.com/cross-rs/cross

Add Dependencies

Install toolchains for specific target platforms:

rustup target add aarch64-apple-darwin

Usage

# (ONCE PER BOOT, on Linux)
# Start Docker daemon (Systemd for WSL2 and SysVinit for other systems)
sudo systemctl start docker

# Build for aarch64
cross build --target aarch64-unknown-linux-gnu

# Test for mips64
cross test --target mips64-unknown-linux-gnuabi64

# Build with LTO for powerpc
cross rustc --target powerpc-unknown-linux-gnu --release -- -C lto

About

基于Rust的仓库管理系统

https://desonglll.github.io/crab_rocket/

License:MIT License


Languages

Language:Rust 80.9%Language:TypeScript 17.8%Language:PLpgSQL 0.6%Language:SCSS 0.3%Language:JavaScript 0.2%Language:HTML 0.1%Language:Dockerfile 0.1%Language:CSS 0.1%Language:Shell 0.0%