mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-04-10 23:15:34 -04:00
chore: Nuxt 4 upgrade (#7426)
This commit is contained in:
21
frontend/app/lib/api/public/explore/cookbooks.ts
Normal file
21
frontend/app/lib/api/public/explore/cookbooks.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
||||
import { ReadCookBook } from "~/lib/api/types/cookbook";
|
||||
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
|
||||
|
||||
const prefix = "/api";
|
||||
const exploreGroupSlug = (groupSlug: string | number) => `${prefix}/explore/groups/${groupSlug}`
|
||||
|
||||
const routes = {
|
||||
cookbooksGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/cookbooks`,
|
||||
cookbooksGroupSlugCookbookId: (groupSlug: string | number, cookbookId: string | number) => `${exploreGroupSlug(groupSlug)}/cookbooks/${cookbookId}`,
|
||||
};
|
||||
|
||||
export class PublicCookbooksApi extends BaseCRUDAPIReadOnly<ReadCookBook> {
|
||||
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
||||
super(
|
||||
requests,
|
||||
routes.cookbooksGroupSlug(groupSlug),
|
||||
(itemId: string | number) => routes.cookbooksGroupSlugCookbookId(groupSlug, itemId)
|
||||
);
|
||||
}
|
||||
}
|
||||
21
frontend/app/lib/api/public/explore/foods.ts
Normal file
21
frontend/app/lib/api/public/explore/foods.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
||||
import { IngredientFood } from "~/lib/api/types/recipe";
|
||||
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
|
||||
|
||||
const prefix = "/api";
|
||||
const exploreGroupSlug = (groupSlug: string | number) => `${prefix}/explore/groups/${groupSlug}`
|
||||
|
||||
const routes = {
|
||||
foodsGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/foods`,
|
||||
foodsGroupSlugFoodId: (groupSlug: string | number, foodId: string | number) => `${exploreGroupSlug(groupSlug)}/foods/${foodId}`,
|
||||
};
|
||||
|
||||
export class PublicFoodsApi extends BaseCRUDAPIReadOnly<IngredientFood> {
|
||||
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
||||
super(
|
||||
requests,
|
||||
routes.foodsGroupSlug(groupSlug),
|
||||
(itemId: string | number) => routes.foodsGroupSlugFoodId(groupSlug, itemId)
|
||||
);
|
||||
}
|
||||
}
|
||||
21
frontend/app/lib/api/public/explore/households.ts
Normal file
21
frontend/app/lib/api/public/explore/households.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
||||
import { HouseholdSummary } from "~/lib/api/types/household";
|
||||
import { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
|
||||
|
||||
const prefix = "/api";
|
||||
const exploreGroupSlug = (groupSlug: string | number) => `${prefix}/explore/groups/${groupSlug}`
|
||||
|
||||
const routes = {
|
||||
householdsGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/households`,
|
||||
householdsGroupSlugHouseholdSlug: (groupSlug: string | number, householdSlug: string | number) => `${exploreGroupSlug(groupSlug)}/households/${householdSlug}`,
|
||||
};
|
||||
|
||||
export class PublicHouseholdApi extends BaseCRUDAPIReadOnly<HouseholdSummary> {
|
||||
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
||||
super(
|
||||
requests,
|
||||
routes.householdsGroupSlug(groupSlug),
|
||||
(itemId: string | number) => routes.householdsGroupSlugHouseholdSlug(groupSlug, itemId)
|
||||
);
|
||||
}
|
||||
}
|
||||
45
frontend/app/lib/api/public/explore/organizers.ts
Normal file
45
frontend/app/lib/api/public/explore/organizers.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
||||
import { RecipeCategory, RecipeTag, RecipeTool } from "~/lib/api/types/recipe";
|
||||
import { ApiRequestInstance } from "~/lib/api/types/non-generated";
|
||||
|
||||
const prefix = "/api";
|
||||
const exploreGroupSlug = (groupSlug: string | number) => `${prefix}/explore/groups/${groupSlug}`
|
||||
|
||||
const routes = {
|
||||
categoriesGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/categories`,
|
||||
categoriesGroupSlugCategoryId: (groupSlug: string | number, categoryId: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/categories/${categoryId}`,
|
||||
tagsGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tags`,
|
||||
tagsGroupSlugTagId: (groupSlug: string | number, tagId: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tags/${tagId}`,
|
||||
toolsGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tools`,
|
||||
toolsGroupSlugToolId: (groupSlug: string | number, toolId: string | number) => `${exploreGroupSlug(groupSlug)}/organizers/tools`,
|
||||
};
|
||||
|
||||
export class PublicCategoriesApi extends BaseCRUDAPIReadOnly<RecipeCategory> {
|
||||
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
||||
super(
|
||||
requests,
|
||||
routes.categoriesGroupSlug(groupSlug),
|
||||
(itemId: string | number) => routes.categoriesGroupSlugCategoryId(groupSlug, itemId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class PublicTagsApi extends BaseCRUDAPIReadOnly<RecipeTag> {
|
||||
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
||||
super(
|
||||
requests,
|
||||
routes.tagsGroupSlug(groupSlug),
|
||||
(itemId: string | number) => routes.tagsGroupSlugTagId(groupSlug, itemId)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class PublicToolsApi extends BaseCRUDAPIReadOnly<RecipeTool> {
|
||||
constructor(requests: ApiRequestInstance, groupSlug: string) {
|
||||
super(
|
||||
requests,
|
||||
routes.toolsGroupSlug(groupSlug),
|
||||
(itemId: string | number) => routes.toolsGroupSlugToolId(groupSlug, itemId)
|
||||
);
|
||||
}
|
||||
}
|
||||
33
frontend/app/lib/api/public/explore/recipes.ts
Normal file
33
frontend/app/lib/api/public/explore/recipes.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { BaseCRUDAPIReadOnly } from "~/lib/api/base/base-clients";
|
||||
import { route } from "../../base";
|
||||
import { Recipe, RecipeSuggestionQuery, RecipeSuggestionResponse } from "~/lib/api/types/recipe";
|
||||
import { ApiRequestInstance, PaginationData } from "~/lib/api/types/non-generated";
|
||||
import { RecipeSearchQuery } from "../../user/recipes/recipe";
|
||||
|
||||
const prefix = "/api";
|
||||
const exploreGroupSlug = (groupSlug: string | number) => `${prefix}/explore/groups/${groupSlug}`
|
||||
|
||||
const routes = {
|
||||
recipesGroupSlug: (groupSlug: string | number) => `${exploreGroupSlug(groupSlug)}/recipes`,
|
||||
recipesGroupSlugRecipeSlug: (groupSlug: string | number, recipeSlug: string | number) => `${exploreGroupSlug(groupSlug)}/recipes/${recipeSlug}`,
|
||||
};
|
||||
|
||||
export class PublicRecipeApi extends BaseCRUDAPIReadOnly<Recipe> {
|
||||
constructor(requests: ApiRequestInstance, private readonly groupSlug: string) {
|
||||
super(
|
||||
requests,
|
||||
routes.recipesGroupSlug(groupSlug),
|
||||
(itemId: string | number) => routes.recipesGroupSlugRecipeSlug(groupSlug, itemId)
|
||||
);
|
||||
}
|
||||
|
||||
async search(rsq: RecipeSearchQuery) {
|
||||
return await this.requests.get<PaginationData<Recipe>>(route(routes.recipesGroupSlug(this.groupSlug), rsq));
|
||||
}
|
||||
|
||||
async getSuggestions(q: RecipeSuggestionQuery, foods: string[] | null = null, tools: string[]| null = null) {
|
||||
return await this.requests.get<RecipeSuggestionResponse>(
|
||||
route(`${routes.recipesGroupSlug(this.groupSlug)}/suggestions`, { ...q, foods, tools })
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user