feat: initial refactor to use marka as backend

This commit is contained in:
Max Richter
2025-10-28 20:15:23 +01:00
parent 0beb3b1071
commit f680b5f832
39 changed files with 245 additions and 1012 deletions

View File

@@ -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);
},
};

View File

@@ -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);
}

View File

@@ -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);
},
};