Skip to content

Commit

Permalink
chore: reduce unneccessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
jooakar committed Feb 2, 2024
1 parent 7cd1055 commit ce7b7f1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
6 changes: 2 additions & 4 deletions src/api/invoices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ pub async fn create(
))
}

pub async fn list_all(
mut conn: DatabaseConnection,
) -> Result<(StatusCode, Json<Vec<PopulatedInvoice>>), Error> {
Ok((StatusCode::OK, axum::Json(conn.list_invoices().await?)))
pub async fn list_all(mut conn: DatabaseConnection) -> Result<Json<Vec<PopulatedInvoice>>, Error> {
Ok(axum::Json(conn.list_invoices().await?))
}
9 changes: 2 additions & 7 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
use axum::{
extract::DefaultBodyLimit,
routing::{get, post},
Router,
};
use axum::{extract::DefaultBodyLimit, routing::get, Router};
use tower_http::{limit::RequestBodyLimitLayer, trace::TraceLayer};

pub mod invoices;

pub fn app() -> Router<crate::database::State> {
Router::new()
.route("/health", get(health))
.route("/invoices", post(invoices::create))
.route("/invoices", get(invoices::list_all))
.route("/invoices", get(invoices::list_all).post(invoices::create))
.layer(TraceLayer::new_for_http())
.layer(DefaultBodyLimit::disable())
.layer(RequestBodyLimitLayer::new(
Expand Down

0 comments on commit ce7b7f1

Please sign in to comment.