Skip to content

Commit

Permalink
update config.toml -> config.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
fankaiLiu committed Dec 29, 2023
1 parent 75c493a commit 2acdad9
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "salvo-cli"
version = "0.1.37"
version = "0.1.38"
edition = "2021"
authors = ["Fankai Liu [email protected]","mrxiaozhuox [email protected]"]
keywords = ["salvo", "cli","template"]
Expand Down
117 changes: 61 additions & 56 deletions src/template/config/config.hbs
Original file line number Diff line number Diff line change
@@ -1,60 +1,65 @@
[server]
name = "{{project_name}}"
address = "0.0.0.0:5800"
ssl = false
cors_allow_origin=["https://salvo.rs"]
server:
name: "{{project_name}}"
address: "0.0.0.0:5800"
ssl: false
cors_allow_origin:
- "https://salvo.rs"

{{#if need_db_conn}}
[database]
{{#if is_sea_orm_or_sqlx}}
{{#if is_postgres}}
database_url="postgresql://liufankai:1@localhost/salvo_demo"
{{/if}}
{{#if is_sqlite}}
database_url="sqlite:data/demo.db"
{{/if}}
{{#if is_mysql}}
database_url="mysql://root:981109@localhost/salvo_demo"
{{/if}}
{{/if}}
{{#if is_diesel}}
{{#if is_postgres}}
database_url="postgres://liufankai:1@localhost/diesel_example"
{{/if}}
{{#if is_sqlite}}
database_url="file:data/test.db"
{{/if}}
{{#if is_mysql}}
database_url="mysql://root:[email protected]:3306/diesel_example"
{{/if}}
{{/if}}
{{#if is_rbatis}}
{{#if is_postgres}}
database_url="postgres://liufankai:1@localhost/rbatis_example"
{{/if}}
{{#if is_sqlite}}
database_url="data/rbatis_sqlite.db"
{{/if}}
{{#if is_mysql}}
database_url="mysql://root:[email protected]:3306/rbatis_example"
{{/if}}
{{#if is_mssql}}
database_url="mssql://SA:TestPass!123456@localhost:1433/rbatis_example"
{{/if}}
{{/if}}
database:
{{#if is_sea_orm_or_sqlx}}
{{#if is_postgres}}
database_url: "postgresql://liufankai:1@localhost/salvo_demo"
{{/if}}
{{#if is_sqlite}}
database_url: "sqlite:data/demo.db"
{{/if}}
{{#if is_mysql}}
database_url: "mysql://root:981109@localhost/salvo_demo"
{{/if}}
{{/if}}
{{#if is_diesel}}
{{#if is_postgres}}
database_url: "postgres://liufankai:1@localhost/diesel_example"
{{/if}}
{{#if is_sqlite}}
database_url: "file:data/test.db"
{{/if}}
{{#if is_mysql}}
database_url: "mysql://root:[email protected]:3306/diesel_example"
{{/if}}
{{/if}}
{{#if is_rbatis}}
{{#if is_postgres}}
database_url: "postgres://liufankai:1@localhost/rbatis_example"
{{/if}}
{{#if is_sqlite}}
database_url: "data/rbatis_sqlite.db"
{{/if}}
{{#if is_mysql}}
database_url: "mysql://root:[email protected]:3306/rbatis_example"
{{/if}}
{{#if is_mssql}}
database_url: "mssql://SA:TestPass!123456@localhost:1433/rbatis_example"
{{/if}}
{{/if}}
{{/if}}
{{#if is_mongodb}}
database_url="mongodb://localhost:27017"
database_url: "mongodb://localhost:27017"
{{/if}}
[jwt]
jwt_secret = "secret"
jwt_exp = 6000
[cert]
cert = "config/certs/cert.pem"
key = "config/certs/key.pem"
[log]
filter_level = "info" # "debug" "info" "warn" "error"
with_ansi = true
to_stdout = true
directory = "./logs"
file_name = "my-service.log"
rolling = "daily" # "minutely" "hourly" "daily" "never"

jwt:
jwt_secret: "secret"
jwt_exp: 6000

cert:
cert: "config/certs/cert.pem"
key: "config/certs/key.pem"

log:
filter_level: "info" # Available options: "debug", "info", "warn", "error"
with_ansi: true
to_stdout: true
directory: "./logs"
file_name: "my-service.log"
rolling: "daily" # Available options: "minutely", "hourly", "daily", "never"
4 changes: 2 additions & 2 deletions src/template/src/config_template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub struct Cert {
pub key: String,
}

const CONFIG_FILE: &str = "config/config.toml";
const CONFIG_FILE: &str = "config/config.yml";

pub static CFG: Lazy<Configs> = Lazy::new(self::Configs::init);

Expand All @@ -69,7 +69,7 @@ impl Configs {
Ok(s) => s,
Err(e) => panic!("{{config_error_read}}", e),
};
match toml::from_str(&cfg_contents){
match serde_yaml::from_str(&cfg_contents){
Ok(c) => c,
Err(e) => panic!("{{config_error_parse}}", e),
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn write_project_file(
"version": "1",
"features": ["full"]
},
"toml": "0.8.0",
"serde_yaml": "0.8.26",
"tracing": "0.1"
},
"is_web_site":is_web_site,
Expand Down Expand Up @@ -527,7 +527,7 @@ fn create_basic_file(
),
//config
(
"config/config.toml",
"config/config.yml",
include_str!("../template/config/config.hbs"),
),
(
Expand Down

0 comments on commit 2acdad9

Please sign in to comment.