Rename item to entry

This commit is contained in:
2023-05-13 15:39:39 -04:00
parent a331e63466
commit bf40b803a9
10 changed files with 89 additions and 89 deletions

View File

@@ -2,8 +2,8 @@ use axum::{extract::State, Json};
use sqlx::PgPool;
use crate::error::Error;
use crate::models::item::{get_items, Item};
use crate::models::entry::{get_entries, Entry};
pub async fn get(State(pool): State<PgPool>) -> Result<Json<Vec<Item>>, Error> {
Ok(Json(get_items(&pool).await?))
pub async fn get(State(pool): State<PgPool>) -> Result<Json<Vec<Entry>>, Error> {
Ok(Json(get_entries(&pool).await?))
}

19
src/handlers/entry.rs Normal file
View File

@@ -0,0 +1,19 @@
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?))
}

View File

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

View File

@@ -1,4 +1,4 @@
pub mod feed;
pub mod feeds;
pub mod item;
pub mod items;
pub mod entry;
pub mod entries;