Crates.io | prkserver |
lib.rs | prkserver |
version | |
source | src |
created_at | 2024-06-07 04:34:59.277993 |
updated_at | 2025-01-06 13:20:31.858953 |
description | `prkserver` is a CLI tool that helps create a backend server in Rust using Axum and SQLx. It configures everything based on a provided `config.toml` file. |
homepage | |
repository | https://github.com/prk-Jr/prkserver.git |
max_upload_size | |
id | 1264387 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
prkserver
is a CLI tool that helps create a backend server in Rust using Axum and SQLx. It configures everything based on a provided config.toml
file.
config.toml
file.To install prkserver
, use cargo:
cargo install prkserver
To use prkserver
, create a config.toml
file that defines the project configuration. Here is an example config.toml
file:
project_name = "backend_project"
database_url = "mysql://user:password@localhost/database_name"
database_type = "mysql" # postgres, mysql, sqlite
[[models]]
name = "User"
table_name = "users"
fields = [
{ name = "id", type = "i32" },
{ name = "username", type = "String" },
{ name = "email", type = "String" },
]
endpoints = [
{ method = "GET", path = "/users" },
{ method = "POST", path = "/users", body_params = [
{ name = "username", type = "String" },
{ name = "email", type = "String" },
] },
]
[[models]]
name = "Todo"
table_name = "todos"
fields = [
{ name = "id", type = "i32" },
{ name = "task", type = "String" },
{ name = "description", type = "Option<String>" },
]
endpoints = [
{ method = "GET", path = "/todos", middlewares = [
"UserLoginHistoryMiddleware",
] },
{ method = "POST", path = "/todos", middlewares = [
"UserLoginHistoryMiddleware",
], body_params = [
{ name = "task", type = "String" },
{ name = "description", type = "Option<String>" },
] },
{ method = "GET", path = "/todos/{id}", path_params = [
{ name = "id", type = "i32" },
] },
]
[[models]]
name = "UserLoginHistory"
table_name = "user_login_history"
fields = [
{ name = "user_id", type = "i32" },
{ name = "token", type = "String" },
]
[[middlewares]]
model = "UserLoginHistory"
select_from_model = "UserLoginHistory"
validate_header = [{ model_field = "token", header_key = "token" }]
Once you have your config.toml file, run prkserver at the path of this config file:
prkserver
This will generate a new project in a directory named after project_name specified in the config.toml.
Note: Still work in Progress.