Skip to content

Commit

Permalink
fix: stubbed type FreshContext
Browse files Browse the repository at this point in the history
  • Loading branch information
vicary committed Oct 8, 2024
1 parent 5895dee commit e35fc3b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vicary/fresh-graphql",
"version": "0.2.10",
"version": "0.2.11",
"exports": "./mod.ts",
"license": "MIT",
"publish": {
Expand Down
48 changes: 43 additions & 5 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,54 @@ export type CreateHandlerOptions = {
/**
* 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.
* Fresh 1.x uses HTTP import which is not compatible with JSR modules, this
* will be a direct export from Fresh when 2.x is out.
*
* ```ts
* import type { FreshContext } from "jsr:@fresh/core@^2.0";
* ```
*/
export type FreshContext = {
request: Request;
};
export interface FreshContext<
State = Record<string, unknown>,
// deno-lint-ignore no-explicit-any
Data = any,
NotFoundData = Data,
> {
/** @types deprecated */
localAddr?: Deno.NetAddr;
remoteAddr: Deno.NetAddr;
url: URL;
basePath: string;
route: string;
/** @deprecated Use `.route` instead */
pattern: string;
destination: "internal" | "static" | "route" | "notFound";
params: Record<string, string>;
isPartial: boolean;
state: State;
config: {
dev: boolean;
build: {
outDir: string;
target: string | string[];
};
staticDir: string;
server: Partial<Deno.ServeTlsOptions>;
basePath: string;
};
data: Data;
/** The error that caused the error page to be loaded. */
error?: unknown;
/** Sringified code frame of the error rendering failed (only in development mode) */
codeFrame?: unknown;

// These properties may be different
renderNotFound: (data?: NotFoundData) => Response | Promise<Response>;
render: (
data?: Data,
) => Response | Promise<Response>;
next: () => Promise<Response>;
}

export function createHandler<TManifest extends Manifest>(
manifest: TManifest,
Expand Down

0 comments on commit e35fc3b

Please sign in to comment.