feat: add cargo generate support

This commit is contained in:
Kristofers Solo 2024-08-20 21:06:10 +03:00
parent db8f668b4b
commit 137ceedadd
8 changed files with 9 additions and 8 deletions

1
.env
View File

@ -1 +0,0 @@
DATABASE_URL=postgres://postgres:password@localhost:5432/axum-template

1
.env.example Normal file
View File

@ -0,0 +1 @@
DATABASE_URL=postgres://postgres:password@localhost:5432/{{project-name}}

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target
.env

View File

@ -1,5 +1,5 @@
[package]
name = "axum-template"
name = "{{project-name}}"
version = "0.1.0"
edition = "2021"
authors = ["Kristofers Solo <dev@kristofers.xyz>"]
@ -9,7 +9,7 @@ path = "src/lib.rs"
[[bin]]
path = "src/main.rs"
name = "axum-template"
name = "{{project-name}}"
[dependencies]
axum = "0.7"

View File

@ -25,7 +25,7 @@ RUN apt-get update -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/axum-template axum-template
COPY --from=builder /app/target/release/{{project-name}} {{project-name}}
COPY config config
ENV APP_ENVIRONMENT production
ENTRYPOINT ["./axum-template"]

View File

@ -6,4 +6,4 @@ host = "127.0.0.1"
port = 5432
username = "postgres"
password = "password"
database_name = "axum-template"
database_name = "{{project-name}}"

View File

@ -1,4 +1,4 @@
use axum_template::{
use {{crate_name}}::{
config::get_config,
routes::route,
telemetry::{get_subscriber, init_subscriber},
@ -8,7 +8,7 @@ use tokio::net::TcpListener;
#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
let subscriber = get_subscriber("axum-template", "info", std::io::stdout);
let subscriber = get_subscriber("{{project-name}}", "info", std::io::stdout);
init_subscriber(subscriber);
let config = get_config().expect("Failed to read configuation.");
let pool = PgPoolOptions::new().connect_lazy_with(config.database.with_db());

View File

@ -1,4 +1,4 @@
use axum_template::{
use {{crate_name}}::{
config::{get_config, DatabaseSettings},
routes::route,
telemetry::{get_subscriber, init_subscriber},