diff --git a/.changeset/ninety-cloths-taste.md b/.changeset/ninety-cloths-taste.md new file mode 100644 index 00000000..b47321d5 --- /dev/null +++ b/.changeset/ninety-cloths-taste.md @@ -0,0 +1,5 @@ +--- +'@hono/cloudflare-access': patch +--- + +Add explicit `MiddlewareHandler` return type diff --git a/packages/cloudflare-access/src/index.ts b/packages/cloudflare-access/src/index.ts index 0f1362c3..f1eb760f 100644 --- a/packages/cloudflare-access/src/index.ts +++ b/packages/cloudflare-access/src/index.ts @@ -1,4 +1,4 @@ -import type { Context } from 'hono' +import type { Context, MiddlewareHandler } from 'hono' import { getCookie } from 'hono/cookie' import { createMiddleware } from 'hono/factory' import { HTTPException } from 'hono/http-exception' @@ -33,7 +33,7 @@ declare module 'hono' { } } -export const cloudflareAccess = (accessTeamName: string) => { +export const cloudflareAccess = (accessTeamName: string): MiddlewareHandler => { // This var will hold already imported jwt keys, this reduces the load of importing the key on every request let cacheKeys: Record = {} let cacheExpiration = 0 diff --git a/packages/cloudflare-access/tsconfig.build.json b/packages/cloudflare-access/tsconfig.build.json index 4dcca72d..8a69eb0f 100644 --- a/packages/cloudflare-access/tsconfig.build.json +++ b/packages/cloudflare-access/tsconfig.build.json @@ -5,6 +5,7 @@ "outDir": "dist", "tsBuildInfoFile": "dist/tsconfig.build.tsbuildinfo", "emitDeclarationOnly": false, + "isolatedDeclarations": true, "types": ["@cloudflare/workers-types"] }, "include": ["src/**/*.ts"],