feat: use Wrangler auto-generated env variables
Summary: Test Plan:
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
||||||
|
|
||||||
import { fetchFromMultipleSources } from "~/libs/fetchFromMultipleSources";
|
import { fetchFromMultipleSources } from "~/libs/fetchFromMultipleSources";
|
||||||
|
import type { Env } from "~/types/env";
|
||||||
import {
|
import {
|
||||||
AniListIdQuerySchema,
|
AniListIdQuerySchema,
|
||||||
ErrorResponse,
|
ErrorResponse,
|
||||||
@@ -42,13 +43,17 @@ const route = createRoute({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const app = new OpenAPIHono<HonoEnv>();
|
const app = new OpenAPIHono<Env>();
|
||||||
|
|
||||||
app.openapi(route, async (c) => {
|
app.openapi(route, async (c) => {
|
||||||
const aniListId = Number(c.req.param("aniListId"));
|
const aniListId = Number(c.req.param("aniListId"));
|
||||||
|
|
||||||
const episodes = await fetchFromMultipleSources([
|
const episodes = await fetchFromMultipleSources([
|
||||||
() => getEpisodesFromAnify(JSON.parse(c.env.ENABLE_ANIFY), aniListId),
|
() =>
|
||||||
|
getEpisodesFromAnify(
|
||||||
|
JSON.parse((c.env?.["ENABLE_ANIFY"] ?? "true") as string),
|
||||||
|
aniListId,
|
||||||
|
),
|
||||||
() => getEpisodesFromConsumet(aniListId),
|
() => getEpisodesFromConsumet(aniListId),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
7
src/types/env.d.ts
vendored
Normal file
7
src/types/env.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Generated by Wrangler on Sun May 26 2024 09:50:50 GMT-0400 (Eastern Daylight Time)
|
||||||
|
// by running `wrangler types src/types/env.d.ts`
|
||||||
|
import type { Env as HonoEnv } from "hono";
|
||||||
|
|
||||||
|
interface Env extends HonoEnv {
|
||||||
|
ENABLE_ANIFY: string;
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
import type { Env as HonoEnv } from "hono";
|
|
||||||
|
|
||||||
export interface Env extends HonoEnv {
|
|
||||||
ENABLE_ANIFY: string;
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user