refactor: changes

This commit is contained in:
Sandro Eiler 2024-01-21 22:00:10 +01:00
parent 476eed4559
commit f4deaceb27
7 changed files with 137 additions and 12 deletions

View file

@ -1,16 +1,18 @@
use axum::routing::IntoMakeService;
use axum::serve::Serve;
use axum::Router;
use sqlx::PgPool;
use tokio::net::TcpListener;
/// API routing
pub fn app() -> Router {
pub fn app(connection: PgPool) -> Router {
Router::new()
.with_state(connection)
.merge(crate::routes::routes_health_check())
.merge(crate::routes::routes_subscriptions())
}
/// Start the server
pub fn run(listener: TcpListener) -> Serve<IntoMakeService<Router>, Router> {
axum::serve(listener, app().into_make_service())
pub fn run(listener: TcpListener, connection: PgPool) -> Serve<IntoMakeService<Router>, Router> {
axum::serve(listener, app(connection).into_make_service())
}