feat: add proxy server
This commit is contained in:
@@ -7,7 +7,7 @@ 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 from "@lib/recipeSchema.ts";
|
||||
import recipeSchema, { isValidRecipe } 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";
|
||||
@@ -93,7 +93,10 @@ async function extractUsingAI(
|
||||
|
||||
const recipe = await openai.extractRecipe(markdown);
|
||||
|
||||
return recipe;
|
||||
if (isValidRecipe(recipe)) {
|
||||
return recipe;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
async function processCreateRecipeFromUrl(
|
||||
|
@@ -9,6 +9,7 @@ import { KMenu } from "@islands/KMenu.tsx";
|
||||
import PageHero from "@components/PageHero.tsx";
|
||||
import { Star } from "@components/Stars.tsx";
|
||||
import { renderMarkdown } from "@lib/documents.ts";
|
||||
import { isValidRecipe } from "@lib/recipeSchema.ts";
|
||||
|
||||
export const handler: Handlers<{ recipe: Recipe; session: unknown } | null> = {
|
||||
async GET(_, ctx) {
|
||||
@@ -24,11 +25,6 @@ export const handler: Handlers<{ recipe: Recipe; session: unknown } | null> = {
|
||||
},
|
||||
};
|
||||
|
||||
function isValidRecipe(recipe: Recipe | null) {
|
||||
return recipe?.ingredients?.length && recipe?.instructions?.length &&
|
||||
recipe.name?.length;
|
||||
}
|
||||
|
||||
function ValidRecipe({
|
||||
recipe,
|
||||
amount,
|
||||
|
Reference in New Issue
Block a user