https://github.com/cm-iv/salvo-starter
An API starter using the Salvo Rust web framework
https://github.com/cm-iv/salvo-starter
Last synced: 3 months ago
JSON representation
An API starter using the Salvo Rust web framework
- Host: GitHub
- URL: https://github.com/cm-iv/salvo-starter
- Owner: CM-IV
- Created: 2024-12-06T14:57:18.000Z (6 months ago)
- Default Branch: master
- Last Pushed: 2025-01-26T17:03:14.000Z (5 months ago)
- Last Synced: 2025-01-26T18:19:30.674Z (5 months ago)
- Language: Rust
- Size: 120 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Introduction
This is a project generated by [salvo-cli](https://github.com/salvo-rs/salvo-cli). You can run the program and test according to the following commands (for non-sqlite databases, please modify the database connection string first according to the tutorial, and complete the initial work of the data).
😄 The latest version of Salvo requires Rust version 1.75. If your compilation fails, please try upgrading with `rustup update`.
``` shell
//Run the project
cargo run
//Run tests
cargo test
```
# Tip
- If you choose sqlite or have initialized the data in the users table, please use the account zhangsan with password 123 to login.
- The database connection string is in config/config.toml, but if you use sqlx or seaorm, the library itself reads the configuration from .env file to generate entities, run migrations, and validate. So when you modify the database connection string, you need to change two places at the same time.
# orm doc or home page link
🎯 You have chosen sqlx, documentation can be viewed here:https://github.com/launchbadge/sqlx
## sqlx_cli
SQLx's associated command-line utility for managing databases, migrations, and enabling "offline" mode with sqlx::query!() and friends. https://github.com/launchbadge/sqlx/blob/main/sqlx-cli/README.md
## Data initialization
You have chosen sqlite database, the database has been initialized in the data folder.
# Project directory description
# salvo_api
- **Dir:** salvo_api
- *File:* deny.toml (License checks are used to verify that each crate you use has license terms that you consider acceptable.)
- *File:* cliff.toml (For generating changelogs with git-cliff)
- **Dir:** .github
- **Dir:** workflows
- *File:* build.yml (This YAML file configures the continuous integration (CI) pipeline for the project. It defines the steps that are executed automatically when code is pushed to the repository. This includes tasks like building the software, running tests, and deploying the application if conditions are met.)
- *File:* .env (Database connection string config file)
- **Dir:** data (Directory containing database files or initialization data sql files)
- *File:* demo.db
- **Dir:** config (Folder containing all configuration files)
- **Dir:** certs (Directory for storing certificate files)
- *File:* cert.pem
- *File:* key.pem
- *File:* config.yml
- *File:* Cargo.toml (Rust project dependency and configuration info)
- **Dir:** assets (Static resources such as images, JavaScript scripts and CSS style sheets)
- *File:* favicon.ico
- **Dir:** src (Source code directory)
- **Dir:** middleware (Module containing middleware)
- *File:* jwt.rs
- *File:* mod.rs
- *File:* handle_404.rs
- *File:* cors.rs
- *File:* config.rs (Module for reading and processing application configuration)
- **Dir:** utils (Module containing utility functions)
- *File:* rand_utils.rs
- *File:* mod.rs
- **Dir:** routers (Module containing route handling functions)
- *File:* mod.rs
- *File:* user.rs
- *File:* demo.rs
- *File:* static_routers.rs
- *File:* main.rs (Entry point of application, sets up and starts services)
- *File:* app_writer.rs (Standardize response)
- *File:* db.rs
- **Dir:** entities (Module defining entities and interacting with database)
- *File:* users.rs
- *File:* mod.rs
- **Dir:** services (Module containing business logic services)
- *File:* mod.rs
- *File:* user.rs
- **Dir:** dtos (Module defining Data Transfer Objects (DTOs) for encapsulating and transporting data)
- *File:* mod.rs
- *File:* user.rs
- *File:* app_error.rs (Provides unified error handling functionality)
- **Dir:** migrations (Database migration script storage location)
- **Dir:** 2021-10-20-000000_create_users_table
- *File:* up.sql# cargo-deny
``` shell
cargo install --locked cargo-deny && cargo deny check
```
# git cliff
Please replace the url in line 49 of the cliff.toml file with the repository url to trigger the automatic generation of changelogs.
# About Salvo
You can view the salvo documentation and more examples at https://salvo.rs/ 📖. If our tools have helped you, please star [salvo](https://github.com/salvo-rs/salvo) and [salvo-cli](https://github.com/salvo-rs/salvo-cli), which will greatly encourage us. ❤️