Skip to content

Commit

Permalink
fix typecheck errors and lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
pcattori committed Jan 20, 2024
1 parent 91b6854 commit 9e2f7bc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions packages/remix-cloudflare-pages/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,18 @@ import { createRequestHandler as createRemixRequestHandler } from "@remix-run/cl
* You can think of this as an escape hatch that allows you to pass
* environment/platform-specific values through to your loader/action.
*/
export type GetLoadContextFunction<Env = unknown> = (
context: Parameters<PagesFunction<Env>>[0]
export type GetLoadContextFunction<
Env = unknown,
Params extends string = any,
Data extends Record<string, unknown> = Record<string, unknown>
> = (
context: EventContext<Env, Params, Data>
) => Promise<AppLoadContext> | AppLoadContext;

export type RequestHandler<Env = any> = PagesFunction<Env>;

export interface createPagesFunctionHandlerParams<Env = any> {
build: ServerBuild;
build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>);
getLoadContext?: GetLoadContextFunction<Env>;
mode?: string;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-server-runtime/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type RequestHandler = (
) => Promise<Response>;

export type CreateRequestHandlerFunction = (
build: ServerBuild | (() => Promise<ServerBuild>),
build: ServerBuild | (() => ServerBuild | Promise<ServerBuild>),
mode?: string
) => RequestHandler;

Expand Down
11 changes: 6 additions & 5 deletions templates/unstable-vite-cloudflare/functions/[[path]].ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { type ServerBuild } from "@remix-run/cloudflare";
import { createPagesFunctionHandler } from "@remix-run/cloudflare-pages";
// eslint-disable-next-line import/no-unresolved
import * as _build from "../build/server";

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const build: ServerBuild = _build as any;
const build = async (): Promise<ServerBuild> => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
// eslint-disable-next-line import/no-unresolved
return import("../build/server");
};

export const onRequest = createPagesFunctionHandler({
build,
getLoadContext: (context) => ({ env: context.env }),
mode: build.mode,
});

0 comments on commit 9e2f7bc

Please sign in to comment.