feat: initial refactor to use marka as backend
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { getRecipe } from "@lib/resource/recipes.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
import { fetchResource } from "@lib/resources.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET(_, ctx) {
|
||||
const recipe = await getRecipe(ctx.params.name);
|
||||
const recipe = await fetchResource(`recipes/${ctx.params.name}`);
|
||||
return json(recipe);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -6,8 +6,8 @@ import { createStreamResponse, isValidUrl } from "@lib/helpers.ts";
|
||||
import * as openai from "@lib/openai.ts";
|
||||
import tds from "https://cdn.skypack.dev/turndown@7.2.0";
|
||||
import { createLogger } from "@lib/log/index.ts";
|
||||
import { createRecipe, Recipe } from "@lib/resource/recipes.ts";
|
||||
import recipeSchema, { isValidRecipe } from "@lib/recipeSchema.ts";
|
||||
import { Recipe } from "@lib/resource/recipes.ts";
|
||||
import recipeSchema from "@lib/recipeSchema.ts";
|
||||
import { fileExtension } from "https://deno.land/x/file_extension@v2.1.0/mod.ts";
|
||||
import { safeFileName } from "@lib/string.ts";
|
||||
import { createDocument } from "@lib/documents.ts";
|
||||
@@ -205,10 +205,10 @@ async function processCreateRecipeFromUrl(
|
||||
streamResponse.enqueue("downloading image");
|
||||
try {
|
||||
streamResponse.enqueue("downloading image");
|
||||
const res = await fetch(src);
|
||||
// const res = await fetch(src);
|
||||
streamResponse.enqueue("saving image");
|
||||
const buffer = await res.arrayBuffer();
|
||||
await createDocument(finalPath, buffer);
|
||||
// const buffer = await res.arrayBuffer();
|
||||
// await createDocument(finalPath, buffer);
|
||||
newRecipe.meta.image = finalPath;
|
||||
} catch (err) {
|
||||
console.log("Failed to save image", err);
|
||||
@@ -218,7 +218,7 @@ async function processCreateRecipeFromUrl(
|
||||
|
||||
streamResponse.enqueue("finished processing, creating file");
|
||||
|
||||
await createRecipe(newRecipe.id, newRecipe);
|
||||
// await createRecipe(newRecipe.id, newRecipe);
|
||||
|
||||
streamResponse.enqueue("id: " + newRecipe.id);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { Handlers } from "$fresh/server.ts";
|
||||
import { getAllRecipes } from "@lib/resource/recipes.ts";
|
||||
import { json } from "@lib/helpers.ts";
|
||||
import { fetchResource } from "@lib/resources.ts";
|
||||
|
||||
export const handler: Handlers = {
|
||||
async GET() {
|
||||
const recipes = await getAllRecipes();
|
||||
const recipes = await fetchResource("recipes");
|
||||
return json(recipes);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user