From 72466f0ea740c1e92e97068892f16ddbf03e5efa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 Jun 2025 11:28:16 +0800 Subject: [PATCH] chore(deps): bump hono from 4.7.11 to 4.8.0 (#19404) --- lib/errors/index.tsx | 3 ++- lib/middleware/debug.ts | 10 ++++++---- lib/middleware/header.ts | 6 ++++-- lib/registry.ts | 3 ++- lib/routes/apnews/topics.ts | 3 ++- package.json | 2 +- pnpm-lock.yaml | 34 +++++++++++++++++----------------- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/lib/errors/index.tsx b/lib/errors/index.tsx index 0ac402793..91bab144a 100644 --- a/lib/errors/index.tsx +++ b/lib/errors/index.tsx @@ -1,4 +1,5 @@ import { type NotFoundHandler, type ErrorHandler } from 'hono'; +import { routePath } from 'hono/route'; import { getDebugInfo, setDebugInfo } from '@/utils/debug-info'; import { config } from '@/config'; import * as Sentry from '@sentry/node'; @@ -11,7 +12,7 @@ import { requestMetric } from '@/utils/otel'; export const errorHandler: ErrorHandler = (error, ctx) => { const requestPath = ctx.req.path; - const matchedRoute = ctx.req.routePath; + const matchedRoute = routePath(ctx); const hasMatchedRoute = matchedRoute !== '/*'; const debug = getDebugInfo(); diff --git a/lib/middleware/debug.ts b/lib/middleware/debug.ts index c9fc8799f..58edeb52a 100644 --- a/lib/middleware/debug.ts +++ b/lib/middleware/debug.ts @@ -1,4 +1,5 @@ import { MiddlewareHandler } from 'hono'; +import { routePath } from 'hono/route'; import { getDebugInfo, setDebugInfo } from '@/utils/debug-info'; const middleware: MiddlewareHandler = async (ctx, next) => { @@ -17,11 +18,12 @@ const middleware: MiddlewareHandler = async (ctx, next) => { { const debug = getDebugInfo(); - const hasMatchedRoute = ctx.req.routePath !== '/*'; - if (!debug.routes[ctx.req.routePath] && hasMatchedRoute) { - debug.routes[ctx.req.routePath] = 0; + const rPath = routePath(ctx); + const hasMatchedRoute = rPath !== '/*'; + if (!debug.routes[rPath] && hasMatchedRoute) { + debug.routes[rPath] = 0; } - hasMatchedRoute && debug.routes[ctx.req.routePath]++; + hasMatchedRoute && debug.routes[rPath]++; if (ctx.res.headers.get('RSSHub-Cache-Status')) { debug.hitCache++; diff --git a/lib/middleware/header.ts b/lib/middleware/header.ts index e6f6ef9a1..0e4d50f84 100644 --- a/lib/middleware/header.ts +++ b/lib/middleware/header.ts @@ -1,4 +1,5 @@ import { MiddlewareHandler } from 'hono'; +import { routePath } from 'hono/route'; import etagCalculate from 'etag'; import { config } from '@/config'; import { Data } from '@/types'; @@ -24,9 +25,10 @@ const middleware: MiddlewareHandler = async (ctx, next) => { ctx.header('Access-Control-Allow-Origin', config.allowOrigin || new URL(ctx.req.url).host); await next(); + const rPath = routePath(ctx); - if (ctx.req.routePath !== '/*') { - ctx.header('X-RSSHub-Route', ctx.req.routePath); + if (rPath !== '/*') { + ctx.header('X-RSSHub-Route', rPath); } const data: Data = ctx.get('data'); diff --git a/lib/registry.ts b/lib/registry.ts index d72339f5a..5887e4974 100644 --- a/lib/registry.ts +++ b/lib/registry.ts @@ -1,6 +1,7 @@ import type { APIRoute, Namespace, Route } from '@/types'; import { directoryImport } from 'directory-import'; import { Hono, type Handler } from 'hono'; +import { routePath } from 'hono/route'; import path from 'node:path'; import { serveStatic } from '@hono/node-server/serve-static'; import { config } from '@/config'; @@ -158,7 +159,7 @@ for (const namespace in namespaces) { for (const [path, routeData] of sortedRoutes) { const wrappedHandler: Handler = async (ctx) => { - logger.debug(`Matched route: ${ctx.req.routePath}`); + logger.debug(`Matched route: ${routePath(ctx)}`); if (!ctx.get('data')) { if (typeof routeData.handler !== 'function') { if (process.env.NODE_ENV === 'test') { diff --git a/lib/routes/apnews/topics.ts b/lib/routes/apnews/topics.ts index 96185f087..272e493e3 100644 --- a/lib/routes/apnews/topics.ts +++ b/lib/routes/apnews/topics.ts @@ -1,3 +1,4 @@ +import { routePath } from 'hono/route'; import { Route, ViewType } from '@/types'; import got from '@/utils/got'; import { load } from 'cheerio'; @@ -37,7 +38,7 @@ export const route: Route = { async function handler(ctx) { const { topic = 'trending-news', nav = '' } = ctx.req.param(); - const useNav = ctx.req.routePath === '/apnews/nav/:nav{.*}?'; + const useNav = routePath(ctx) === '/apnews/nav/:nav{.*}?'; const url = useNav ? `${HOME_PAGE}/${nav}` : `${HOME_PAGE}/hub/${topic}`; const response = await got(url); const $ = load(response.data); diff --git a/package.json b/package.json index 8207dfb2b..a8c59b518 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "fanfou-sdk": "5.0.0", "form-data": "4.0.3", "googleapis": "150.0.1", - "hono": "4.7.11", + "hono": "4.8.0", "html-to-text": "9.0.5", "http-cookie-agent": "6.0.8", "https-proxy-agent": "7.0.6", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d7968e760..2848ff7c1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,10 +49,10 @@ importers: version: 4.2.0(patch_hash=2dfb8d9be036009fcc315551cb39b08f478c9a279511267cf570a3486073d39b) '@hono/node-server': specifier: 1.14.4 - version: 1.14.4(hono@4.7.11) + version: 1.14.4(hono@4.8.0) '@hono/zod-openapi': specifier: 0.19.8 - version: 0.19.8(hono@4.7.11)(zod@3.25.67) + version: 0.19.8(hono@4.8.0)(zod@3.25.67) '@notionhq/client': specifier: 3.1.3 version: 3.1.3 @@ -85,7 +85,7 @@ importers: version: 0.0.25 '@scalar/hono-api-reference': specifier: 0.9.4 - version: 0.9.4(hono@4.7.11) + version: 0.9.4(hono@4.8.0) '@sentry/node': specifier: 9.30.0 version: 9.30.0 @@ -141,8 +141,8 @@ importers: specifier: 150.0.1 version: 150.0.1 hono: - specifier: 4.7.11 - version: 4.7.11 + specifier: 4.8.0 + version: 4.8.0 html-to-text: specifier: 9.0.5 version: 9.0.5 @@ -3964,8 +3964,8 @@ packages: hmacsha1@1.0.0: resolution: {integrity: sha512-4FP6J0oI8jqb6gLLl9tSwVdosWJ/AKSGJ+HwYf6Ixe4MUcEkst4uWzpVQrNOCin0fzTRQbXV8ePheU8WiiDYBw==} - hono@4.7.11: - resolution: {integrity: sha512-rv0JMwC0KALbbmwJDEnxvQCeJh+xbS3KEWW5PC9cMJ08Ur9xgatI0HmtgYZfOdOSOeYsp5LO2cOhdI8cLEbDEQ==} + hono@4.8.0: + resolution: {integrity: sha512-NoiHrqJxoe1MYXqW+/0/Q4NCizKj2Ivm4KmX8mOSBtw9UJ7KYaOGKkO7csIwO5UlZpfvVRdcgiMb0GGyjEjtcw==} engines: {node: '>=16.9.0'} hookable@5.5.3: @@ -7361,20 +7361,20 @@ snapshots: '@fastify/busboy@2.1.1': {} - '@hono/node-server@1.14.4(hono@4.7.11)': + '@hono/node-server@1.14.4(hono@4.8.0)': dependencies: - hono: 4.7.11 + hono: 4.8.0 - '@hono/zod-openapi@0.19.8(hono@4.7.11)(zod@3.25.67)': + '@hono/zod-openapi@0.19.8(hono@4.8.0)(zod@3.25.67)': dependencies: '@asteasolutions/zod-to-openapi': 7.3.3(zod@3.25.67) - '@hono/zod-validator': 0.7.0(hono@4.7.11)(zod@3.25.67) - hono: 4.7.11 + '@hono/zod-validator': 0.7.0(hono@4.8.0)(zod@3.25.67) + hono: 4.8.0 zod: 3.25.67 - '@hono/zod-validator@0.7.0(hono@4.7.11)(zod@3.25.67)': + '@hono/zod-validator@0.7.0(hono@4.8.0)(zod@3.25.67)': dependencies: - hono: 4.7.11 + hono: 4.8.0 zod: 3.25.67 '@humanfs/core@0.19.1': {} @@ -8121,10 +8121,10 @@ snapshots: dependencies: '@scalar/types': 0.2.3 - '@scalar/hono-api-reference@0.9.4(hono@4.7.11)': + '@scalar/hono-api-reference@0.9.4(hono@4.8.0)': dependencies: '@scalar/core': 0.3.3 - hono: 4.7.11 + hono: 4.8.0 '@scalar/openapi-types@0.3.3': dependencies: @@ -10199,7 +10199,7 @@ snapshots: hmacsha1@1.0.0: {} - hono@4.7.11: {} + hono@4.8.0: {} hookable@5.5.3: {}