refactor: remove some duplicated code

This commit is contained in:
2023-08-01 17:50:00 +02:00
parent 01697a6686
commit c5cf629482
30 changed files with 377 additions and 321 deletions

View File

@ -1,4 +1,4 @@
import { HandlerContext } from "$fresh/server.ts";
import { HandlerContext, Handlers } from "$fresh/server.ts";
import {
ImageMagick,
initializeImageMagick,
@ -6,6 +6,7 @@ import {
} from "https://deno.land/x/imagemagick_deno@0.0.14/mod.ts";
import { parseMediaType } from "https://deno.land/std@0.175.0/media_types/parse_media_type.ts";
import * as cache from "@lib/cache/image.ts";
import { SILVERBULLET_SERVER } from "@lib/env.ts";
await initializeImageMagick();
@ -81,7 +82,7 @@ function parseParams(reqUrl: URL) {
};
}
export const handler = async (
const GET = async (
_req: Request,
_ctx: HandlerContext,
): Promise<Response> => {
@ -92,7 +93,7 @@ export const handler = async (
return new Response(params, { status: 400 });
}
const imageUrl = Deno.env.get("SILVERBULLET_SERVER") + "/" + params.image;
const imageUrl = SILVERBULLET_SERVER + "/" + params.image;
console.log("[api/image] " + imageUrl);
@ -138,3 +139,7 @@ export const handler = async (
},
});
};
export const handler: Handlers = {
GET,
};