Add maud for frontend and move api to sub module

This commit is contained in:
2023-06-01 00:03:00 -04:00
parent 9059894021
commit 1698ef9c60
10 changed files with 58 additions and 10 deletions

View File

@@ -1,19 +0,0 @@
use axum::{
extract::{Path, State},
Json,
};
use sqlx::PgPool;
use crate::error::Error;
use crate::models::entry::{create_entry, get_entry, CreateEntry, Entry};
pub async fn get(State(pool): State<PgPool>, Path(id): Path<i32>) -> Result<Json<Entry>, Error> {
Ok(Json(get_entry(&pool, id).await?))
}
pub async fn post(
State(pool): State<PgPool>,
Json(payload): Json<CreateEntry>,
) -> Result<Json<Entry>, Error> {
Ok(Json(create_entry(&pool, payload).await?))
}