mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-24 15:49:42 +02:00
Feature/shareable recipes (#866)
* simplify context menu * move computed to comp-api * feat: ✨ create share tokens for recipes for sharing recieps to non-users * feat: ✨ shareable recipe links with og tags
This commit is contained in:
parent
ba4107348f
commit
b2673d75bf
25 changed files with 914 additions and 199 deletions
|
@ -1,5 +1,6 @@
|
|||
import { CreateAsset, ParsedIngredient, Parser, RecipeZipToken, BulkCreatePayload } from "./types";
|
||||
import { CommentsApi } from "./recipe-comments";
|
||||
import { RecipeShareApi } from "./recipe-share";
|
||||
import { BaseCRUDAPI } from "~/api/_base";
|
||||
|
||||
import { Recipe, CreateRecipe } from "~/types/api-types/recipe";
|
||||
|
@ -26,18 +27,22 @@ const routes = {
|
|||
|
||||
recipesSlugComments: (slug: string) => `${prefix}/recipes/${slug}/comments`,
|
||||
recipesSlugCommentsId: (slug: string, id: number) => `${prefix}/recipes/${slug}/comments/${id}`,
|
||||
|
||||
recipeShareToken: (token: string) => `${prefix}/recipes/shared/${token}`,
|
||||
};
|
||||
|
||||
export class RecipeAPI extends BaseCRUDAPI<Recipe, CreateRecipe> {
|
||||
baseRoute: string = routes.recipesBase;
|
||||
itemRoute = routes.recipesRecipeSlug;
|
||||
|
||||
public comments: CommentsApi;
|
||||
comments: CommentsApi;
|
||||
share: RecipeShareApi;
|
||||
|
||||
constructor(requests: ApiRequestInstance) {
|
||||
super(requests);
|
||||
|
||||
this.comments = new CommentsApi(requests);
|
||||
this.share = new RecipeShareApi(requests);
|
||||
}
|
||||
|
||||
async getAllByCategory(categories: string[]) {
|
||||
|
@ -116,4 +121,8 @@ export class RecipeAPI extends BaseCRUDAPI<Recipe, CreateRecipe> {
|
|||
getZipRedirectUrl(recipeSlug: string, token: string) {
|
||||
return `${routes.recipesRecipeSlugExportZip(recipeSlug)}?token=${token}`;
|
||||
}
|
||||
|
||||
async getShared(item_id: string) {
|
||||
return await this.requests.get<Recipe>(routes.recipeShareToken(item_id));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue