From b6f3bc674ba8987e32c0207290fc1230ace4d82b Mon Sep 17 00:00:00 2001 From: Jonathan Haines Date: Mon, 9 Jun 2025 19:12:04 +1000 Subject: [PATCH] refactor(cloudflare-access): enable isolated declarations (#1195) --- .changeset/ninety-cloths-taste.md | 5 +++++ packages/cloudflare-access/src/index.ts | 4 ++-- packages/cloudflare-access/tsconfig.build.json | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/ninety-cloths-taste.md 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"],