refactor: remove some duplicated code
This commit is contained in:
@ -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,
|
||||
};
|
||||
|
Reference in New Issue
Block a user