From 9fc57d45b53127a53fcf7a4114875af334392f18 Mon Sep 17 00:00:00 2001 From: Max Richter Date: Fri, 21 Jun 2024 11:36:23 +0200 Subject: [PATCH] fix: chatgpt prompts --- deno.json | 24 +++++++++++++----------- lib/env.ts | 3 ++- lib/resource/articles.ts | 8 +++----- main.ts | 3 +-- routes/_middleware.ts | 2 +- routes/api/auth/callback.ts | 2 +- routes/api/auth/login.ts | 2 +- routes/api/auth/logout.ts | 2 +- routes/api/images/index.ts | 2 +- routes/api/series/enhance/[name].ts | 11 +++-------- 10 files changed, 27 insertions(+), 32 deletions(-) diff --git a/deno.json b/deno.json index 1213508..b689706 100644 --- a/deno.json +++ b/deno.json @@ -10,25 +10,27 @@ }, "lint": { "rules": { "tags": ["fresh", "recommended"] } }, "imports": { - "typesense": "https://raw.githubusercontent.com/bradenmacdonald/typesense-deno/main/mod.ts", - "yaml": "https://deno.land/std@0.197.0/yaml/mod.ts", - "@lib": "./lib", - "@lib/": "./lib/", + "$fresh/": "https://deno.land/x/fresh@1.6.8/", "@components": "./components", "@components/": "./components/", "@islands": "./islands", "@islands/": "./islands/", - "zod": "https://deno.land/x/zod@v3.21.4/mod.ts", - "$fresh/": "https://deno.land/x/fresh@1.6.8/", - "preact": "https://esm.sh/preact@10.19.6", - "preact/": "https://esm.sh/preact@10.19.6/", - "preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.2", + "@lib": "./lib", + "@lib/": "./lib/", "@preact/signals": "https://esm.sh/*@preact/signals@1.2.2", "@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.5.1", - "$std/": "https://deno.land/std@0.193.0/", + "@std/dotenv": "jsr:@std/dotenv@^0.224.0", + "@std/http": "jsr:@std/http@^0.224.5", + "@std/yaml": "jsr:@std/yaml@^0.224.1", + "preact": "https://esm.sh/preact@10.19.6", + "preact-render-to-string": "https://esm.sh/*preact-render-to-string@6.2.2", + "preact/": "https://esm.sh/preact@10.19.6/", "tailwindcss": "npm:tailwindcss@3.3.5", "tailwindcss/": "npm:/tailwindcss@3.3.5/", - "tailwindcss/plugin": "npm:/tailwindcss@3.3.5/plugin.js" + "tailwindcss/plugin": "npm:/tailwindcss@3.3.5/plugin.js", + "typesense": "https://raw.githubusercontent.com/bradenmacdonald/typesense-deno/main/mod.ts", + "yaml": "https://deno.land/std@0.197.0/yaml/mod.ts", + "zod": "https://deno.land/x/zod@v3.21.4/mod.ts" }, "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "preact" }, "exclude": ["**/_fresh/*"] diff --git a/lib/env.ts b/lib/env.ts index 96c6d73..5f72e8e 100644 --- a/lib/env.ts +++ b/lib/env.ts @@ -1,4 +1,5 @@ -import "https://deno.land/std/dotenv/load.ts"; +import "@std/dotenv/load"; + export const SILVERBULLET_SERVER = Deno.env.get("SILVERBULLET_SERVER"); export const REDIS_HOST = Deno.env.get("REDIS_HOST"); export const REDIS_PASS = Deno.env.get("REDIS_PASS"); diff --git a/lib/resource/articles.ts b/lib/resource/articles.ts index b034a6a..8b76558 100644 --- a/lib/resource/articles.ts +++ b/lib/resource/articles.ts @@ -1,7 +1,6 @@ import { parseDocument } from "@lib/documents.ts"; -import { parse } from "yaml"; +import { parse, stringify } from "@std/yaml"; import { createCrud } from "@lib/crud.ts"; -import { stringify } from "$std/yaml/stringify.ts"; import { extractHashTags, formatDate } from "@lib/string.ts"; import { fixRenderedMarkdown } from "@lib/helpers.ts"; @@ -29,14 +28,13 @@ function renderArticle(article: Article) { meta.date = formatDate(meta.date); } - return fixRenderedMarkdown(`${ - meta + return fixRenderedMarkdown(`${meta ? `--- ${stringify(meta)} ---` : `--- ---` - } + } # ${article.name} ${article.tags.map((t) => `#${t}`).join(" ")} ${article.content} diff --git a/main.ts b/main.ts index 1990aa8..404bfb0 100644 --- a/main.ts +++ b/main.ts @@ -4,11 +4,10 @@ /// /// -import "$std/dotenv/load.ts"; +import "@std/dotenv/load"; import { start } from "$fresh/server.ts"; import manifest from "./fresh.gen.ts"; import config from "./fresh.config.ts"; await start(manifest, config); - diff --git a/routes/_middleware.ts b/routes/_middleware.ts index 71d207c..18d65d1 100644 --- a/routes/_middleware.ts +++ b/routes/_middleware.ts @@ -1,7 +1,7 @@ //routes/middleware-error-handler/_middleware.ts import { MiddlewareHandlerContext } from "$fresh/server.ts"; import { DomainError } from "@lib/errors.ts"; -import { getCookies } from "https://deno.land/std@0.197.0/http/cookie.ts"; +import { getCookies } from "@std/http/cookie"; import { verify } from "https://deno.land/x/djwt@v2.2/mod.ts"; import * as cache from "@lib/cache/performance.ts"; import { JWT_SECRET } from "@lib/env.ts"; diff --git a/routes/api/auth/callback.ts b/routes/api/auth/callback.ts index 7f7267f..606986d 100644 --- a/routes/api/auth/callback.ts +++ b/routes/api/auth/callback.ts @@ -1,7 +1,7 @@ import { Handlers } from "$fresh/server.ts"; import { create, getNumericDate } from "https://deno.land/x/djwt@v2.2/mod.ts"; import { oauth2Client } from "@lib/auth.ts"; -import { getCookies, setCookie } from "$std/http/cookie.ts"; +import { getCookies, setCookie } from "@std/http/cookie"; import { codeChallengeMap } from "./login.ts"; import { GITEA_SERVER, JWT_SECRET, SESSION_DURATION } from "@lib/env.ts"; import { userDB } from "@lib/db.ts"; diff --git a/routes/api/auth/login.ts b/routes/api/auth/login.ts index fde929f..e0c68ef 100644 --- a/routes/api/auth/login.ts +++ b/routes/api/auth/login.ts @@ -1,6 +1,6 @@ import { Handlers } from "$fresh/server.ts"; import { oauth2Client } from "@lib/auth.ts"; -import { setCookie } from "$std/http/cookie.ts"; +import { setCookie } from "@std/http/cookie"; export const codeChallengeMap = new Map< string, diff --git a/routes/api/auth/logout.ts b/routes/api/auth/logout.ts index 5bbbde4..de17fd0 100644 --- a/routes/api/auth/logout.ts +++ b/routes/api/auth/logout.ts @@ -1,4 +1,4 @@ -import { deleteCookie } from "https://deno.land/std@0.197.0/http/cookie.ts"; +import { deleteCookie } from "@std/http/cookie"; import { Handlers } from "$fresh/server.ts"; export const handler: Handlers = { diff --git a/routes/api/images/index.ts b/routes/api/images/index.ts index 528f3ba..4e0f631 100644 --- a/routes/api/images/index.ts +++ b/routes/api/images/index.ts @@ -6,7 +6,7 @@ import { MagickGeometry, } from "https://deno.land/x/imagemagick_deno@0.0.25/mod.ts"; -import { parseMediaType } from "https://deno.land/std@0.175.0/media_types/parse_media_type.ts"; +import { parseMediaType } from "https://deno.land/std@0.224.0/media_types/parse_media_type.ts"; import * as cache from "@lib/cache/image.ts"; import { SILVERBULLET_SERVER } from "@lib/env.ts"; import { ConcurrentPromiseQueue, PromiseQueue } from "@lib/promise.ts"; diff --git a/routes/api/series/enhance/[name].ts b/routes/api/series/enhance/[name].ts index e17420d..fcbf712 100644 --- a/routes/api/series/enhance/[name].ts +++ b/routes/api/series/enhance/[name].ts @@ -1,20 +1,15 @@ import { HandlerContext, Handlers } from "$fresh/server.ts"; -import { - createDocument, - getDocument, - transformDocument, -} from "@lib/documents.ts"; +import { createDocument } from "@lib/documents.ts"; import { fileExtension } from "https://deno.land/x/file_extension@v2.1.0/mod.ts"; import * as tmdb from "@lib/tmdb.ts"; -import { parse, stringify } from "https://deno.land/std@0.194.0/yaml/mod.ts"; -import { formatDate, safeFileName } from "@lib/string.ts"; +import { safeFileName } from "@lib/string.ts"; import { json } from "@lib/helpers.ts"; import { AccessDeniedError, BadRequestError, NotFoundError, } from "@lib/errors.ts"; -import { createSeries, getSeries, Series } from "@lib/resource/series.ts"; +import { createSeries, getSeries } from "@lib/resource/series.ts"; import * as cache from "@lib/cache/cache.ts"; const isString = (input: string | undefined): input is string => {