1 个不稳定版本
0.1.0 | 2021年9月26日 |
---|
#1277 在 HTTP服务器
34KB
633 行
Hermod
Hermod 项目目前是一个分为两个项目(api 和 www)的单仓。
Api 包含一个 Rust 服务器应用程序可执行文件,作为我们项目的后端。
Www 包含一个 React Web服务器,作为我们项目的前端。
Spec.yaml 包含我们项目部署的 Digital Ocean 应用程序规范。
API
运行API
依赖项
Mac/Linux 的安装说明
cd api
# Install Rust, psql, and Docker
brew install rustup postgres # Install Rustup and psql command line tool
brew cask install docker # Install Docker
# Build and run application
./scripts/init_db.sh # Starts and migrates a Postgres database using Docker
cargo +nightly run # Compiles and runs the Hermod project using an edge Rust build (aka cargo r)
在 api 文件夹的 README 中可以找到在 api 项目中开发时有用的附加命令。
Hermod api
有关运行项目的说明,请参阅 仓库级别的 README。
Rust 项目文档
要查看项目的自动生成文档,请在本地运行 cargo doc --open
,或在线查看 最新版本。
有用的命令
# Install optional Rust command-line utilities
cargo install sqlx-cli # (Optionally) Install sqlx CLI
cargo install bunyan # (Optionally) install Bunyan log formatter
# Other useful commands
cargo doc --open # Compiles and opens project documentation (aka cargo d)
cargo test # Runs unit and integration tests (aka cargo t)
cargo r | bunyan # Compiles and runs the project, piping log output to the Bunyan formatter
TEST_LOG=true cargo t | bunyan # Runs tests with logging, piping output to Bunyan
./scripts/stop_db.sh # Stops the PostgresDB Docker container
sqlx mig add YOUR_MIGRATION_NAME # Create a new sqlx migration
sqlx mig run # Run your new migration
cargo sqlx prepare -- --bin hermod # Rebuild sqlx's cache used for compile-time SQL guarantees
docker build -t hermod_api . # Build the release image of the application (will take a *very* long time, Rust has infamously long release compilation times)
docker run -p 8000:8000 hermod_api # Run the release image of the application
项目架构
- configurations 包含三个文件 - base.yaml,local.yaml 和 production.yaml。base.yaml 包含本地和生产的默认配置,而 local 和 production 分别指定本地和生产的配置设置。
- migrations
- scripts
- src
- tests
- .env
- Cargo.toml
- Dockerfile
- sqlx-data.json
依赖项
~31–45MB
~880K SLoC