1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-21 14:19:41 +02:00
mealie/frontend/api/class-interfaces/recipes/recipe-comments.ts

20 lines
644 B
TypeScript
Raw Normal View History

import { BaseCRUDAPI } from "~/api/_base";
2022-05-21 21:22:02 +02:00
import { RecipeCommentCreate, RecipeCommentOut, RecipeCommentUpdate } from "~/types/api-types/recipe";
const prefix = "/api";
const routes = {
comment: `${prefix}/comments`,
byRecipe: (id: string) => `${prefix}/recipes/${id}/comments`,
commentsId: (id: string) => `${prefix}/comments/${id}`,
};
2022-05-21 21:22:02 +02:00
export class CommentsApi extends BaseCRUDAPI<RecipeCommentCreate, RecipeCommentOut, RecipeCommentUpdate> {
baseRoute: string = routes.comment;
itemRoute = routes.commentsId;
async byRecipe(slug: string) {
2022-05-21 21:22:02 +02:00
return await this.requests.get<RecipeCommentOut[]>(routes.byRecipe(slug));
}
}