Refactored and fixed api endpoints

This commit is contained in:
Benjamin Sherriff
2023-12-02 13:52:01 -05:00
parent 046bf51697
commit dc2ff172b0
11 changed files with 238 additions and 182 deletions

View File

@@ -1,7 +1,7 @@
use actix_web::{get, post, put, delete, web, HttpResponse, HttpRequest, ResponseError};
use log::error;
use serde::{Serialize, Deserialize};
use siren::{GetResponse, Metadata, ServiceError};
use siren::{Response, Metadata, ServiceError};
use crate::{dnd::spells::{QuerySpell, QueryFilters}, auth::{JwtAuth, verify_role}};
@@ -90,7 +90,7 @@ async fn get_all(req: HttpRequest) -> HttpResponse {
spell.id = Some(id);
response.push(spell);
}
HttpResponse::Ok().json(GetResponse {
HttpResponse::Ok().json(Response {
data: response,
metadata: Some(Metadata {
total: total_count as i32,
@@ -121,7 +121,7 @@ async fn get_by_id(id: web::Path<String>) -> HttpResponse {
let id = query_spell.id;
let mut spell = Spell::from(query_spell);
spell.id = Some(id);
HttpResponse::Ok().json(GetResponse {
HttpResponse::Ok().json(Response {
data: spell,
metadata: None
})