Initial commit with basic axum and sqlx API

This commit is contained in:
2023-05-07 17:41:45 -04:00
commit c2c0f7a28d
13 changed files with 2355 additions and 0 deletions

9
src/handlers/items.rs Normal file
View File

@@ -0,0 +1,9 @@
use axum::{extract::State, Json};
use sqlx::PgPool;
use crate::error::AppError;
use crate::models::item::{get_items, Item};
pub async fn get(State(pool): State<PgPool>) -> Result<Json<Vec<Item>>, AppError> {
Ok(Json(get_items(pool).await?))
}