From 08fdb83dc49748205ed185d41a8383d9f310aad6 Mon Sep 17 00:00:00 2001 From: Drew DeCarme Date: Mon, 6 Nov 2023 09:55:19 -0500 Subject: [PATCH] feat: Declare `Env` globally --- packages/core/src/app/App.ts | 2 +- packages/core/src/route/Route.ts | 1 - packages/core/src/route/route.types.ts | 1 - packages/core/src/utils/util.env.ts | 45 ++++++++++++-------------- packages/core/src/utils/util.types.ts | 2 -- 5 files changed, 22 insertions(+), 29 deletions(-) diff --git a/packages/core/src/app/App.ts b/packages/core/src/app/App.ts index 133e0a4..045b62b 100644 --- a/packages/core/src/app/App.ts +++ b/packages/core/src/app/App.ts @@ -1,4 +1,4 @@ -import type { Env, HandlerArgs, Middleware } from "../utils"; +import type { HandlerArgs, Middleware } from "../utils"; import { ErrorNotFound, errorHandler, log } from "../utils"; import type { Route } from "../route/Route"; import type { LogLevel, LoggingType } from "@flare-city/logger"; diff --git a/packages/core/src/route/Route.ts b/packages/core/src/route/Route.ts index 61211b9..d33b96d 100644 --- a/packages/core/src/route/Route.ts +++ b/packages/core/src/route/Route.ts @@ -1,5 +1,4 @@ import type { - Env, ApiResponse, RequestURLSegments, RequestURLSearchParams, diff --git a/packages/core/src/route/route.types.ts b/packages/core/src/route/route.types.ts index 620bdf5..c2b12b1 100644 --- a/packages/core/src/route/route.types.ts +++ b/packages/core/src/route/route.types.ts @@ -3,7 +3,6 @@ import type { RequestURLSearchParams, RequestURLSegments, Middleware, - Env, ApiResponse, } from "../utils"; diff --git a/packages/core/src/utils/util.env.ts b/packages/core/src/utils/util.env.ts index 01e006b..0f4b2ac 100644 --- a/packages/core/src/utils/util.env.ts +++ b/packages/core/src/utils/util.env.ts @@ -1,28 +1,25 @@ import type { LogLevel, LoggingType } from "@flare-city/logger"; -export interface Env { - // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/ - // MY_KV_NAMESPACE: KVNamespace; - // - // Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/ - // MY_DURABLE_OBJECT: DurableObjectNamespace; - // - // Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/ - // MY_BUCKET: R2Bucket; - // - // Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/ - // MY_SERVICE: Fetcher; - // - // Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/ - // MY_QUEUE: Queue; - // - // Vars: - API_AUTH0_DOMAIN: string; - API_AUTH0_CLIENT_ID: string; - API_AUTH0_CLIENT_AUDIENCE: string; - DATABASE_URL: string; - LOG_LEVEL: LogLevel; - LOG_TYPE: LoggingType; +declare global { + interface Env { + // Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/ + // MY_KV_NAMESPACE: KVNamespace; + // + // Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/ + // MY_DURABLE_OBJECT: DurableObjectNamespace; + // + // Example binding to R2. Learn more at https://developers.cloudflare.com/workers/runtime-apis/r2/ + // MY_BUCKET: R2Bucket; + // + // Example binding to a Service. Learn more at https://developers.cloudflare.com/workers/runtime-apis/service-bindings/ + // MY_SERVICE: Fetcher; + // + // Example binding to a Queue. Learn more at https://developers.cloudflare.com/queues/javascript-apis/ + // MY_QUEUE: Queue; + // + // Vars: - HYPERDRIVE: Hyperdrive; + LOG_LEVEL: LogLevel; + LOG_TYPE: LoggingType; + } } diff --git a/packages/core/src/utils/util.types.ts b/packages/core/src/utils/util.types.ts index b39683a..c25bf01 100644 --- a/packages/core/src/utils/util.types.ts +++ b/packages/core/src/utils/util.types.ts @@ -1,5 +1,3 @@ -import type { Env } from "./util.env"; - export type ApiResponse> = { data: T; meta?: M;