From d25ede88b80b4506b224360f3af6f859f2196441 Mon Sep 17 00:00:00 2001 From: Vicary A Date: Tue, 8 Oct 2024 15:22:21 +0800 Subject: [PATCH] fix(deps): remove http import of fresh --- deno.json | 1 + deps.ts | 1 - server.ts | 18 ++++++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/deno.json b/deno.json index b16649a..d57d90f 100644 --- a/deno.json +++ b/deno.json @@ -2,6 +2,7 @@ "name": "@vicary/fresh-graphql", "version": "0.2.10-alpha.0", "exports": "./mod.ts", + "license": "MIT", "publish": { "exclude": [ ".github/**", diff --git a/deps.ts b/deps.ts index 9f4d866..b37c835 100644 --- a/deps.ts +++ b/deps.ts @@ -1,4 +1,3 @@ -export type { FreshContext } from "https://deno.land/x/fresh@1.6.8/server.ts"; export { assert } from "jsr:@std/assert@^0.219.1/assert"; export * as colors from "jsr:@std/fmt@^0.219.1/colors"; export { ensureDir } from "jsr:@std/fs@^0.219.1/ensure_dir"; diff --git a/server.ts b/server.ts index 22ecaad..f98b2a7 100644 --- a/server.ts +++ b/server.ts @@ -1,4 +1,4 @@ -import { createYoga, type FreshContext } from "./deps.ts"; +import { createYoga } from "./deps.ts"; import type { Manifest } from "./schema.ts"; import { fromManifest } from "./schema.ts"; @@ -6,10 +6,24 @@ export type CreateHandlerOptions = { debug?: boolean; }; +/** + * A stubbed version of FreshContext. + * + * Fresh 1.x uses HTTP import which is not compatible with JSR modules, to be + * updated when Fresh 2.x is released. + * + * ```ts + * import type { FreshContext } from "jsr:@fresh/core@^2.0"; + * ``` + */ +export type FreshContext = { + request: Request; +}; + export function createHandler( manifest: TManifest, options?: CreateHandlerOptions, -) { +): (req: Request, ctx: FreshContext) => Promise { // FRSH_GQL_DEV is set when you start the GraphQL development server in dev.ts. const debug = options?.debug ?? Deno.env.has("FRSH_GQL_DEV");