(app: Hono<E>)
| 25 | * - Retroactively instruments sub-apps mounted before `sentry()` was called. |
| 26 | */ |
| 27 | export function applyPatches<E extends Env>(app: Hono<E>): void { |
| 28 | // Always call — installRouteHookOnPrototype is idempotent and returns existing handle when prototype already patched |
| 29 | _routeHook = installRouteHookOnPrototype(); |
| 30 | |
| 31 | // `app.use` (instance own property) — wraps middleware at registration time on this instance. |
| 32 | patchAppUse(app); |
| 33 | |
| 34 | // `app.get`, `app.post`, … (instance own properties) — wraps inline middleware (all-but-last handler). |
| 35 | patchHttpMethodHandlers(app); |
| 36 | |
| 37 | patchAppRequest(app); |
| 38 | |
| 39 | _routeHook.activate(); |
| 40 | |
| 41 | const pendingSubApps = _routeHook.getPendingSubApps(); |
| 42 | |
| 43 | if (pendingSubApps.size > 0) { |
| 44 | DEBUG_BUILD && |
| 45 | debug.log( |
| 46 | `[hono] ${pendingSubApps.size} sub-app(s) were mounted before sentry(). Tracing is applied retroactively. Consider registering sentry() before calling app.route().`, |
| 47 | ); |
| 48 | } |
| 49 | |
| 50 | for (const subApp of pendingSubApps) { |
| 51 | wrapSubAppMiddleware(subApp.routes as HonoRoute[]); |
| 52 | patchAppRequest(subApp); |
| 53 | } |
| 54 | |
| 55 | pendingSubApps.clear(); |
| 56 | } |
no test coverage detected