MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / patchAppUse

Function patchAppUse

packages/hono/src/shared/patchAppUse.ts:19–40  ·  view source on GitHub ↗
(app: Hono<E>)

Source from the content-addressed store, hash-verified

17 * Idempotent.
18 */
19export function patchAppUse<E extends Env>(app: Hono<E>): void {
20 if (patchedUseInstances.has(app)) {
21 DEBUG_BUILD && debug.log('[hono] app.use already patched — skipping.');
22 return;
23 }
24
25 patchedUseInstances.add(app);
26
27 app.use = new Proxy(app.use, {
28 apply(target: typeof app.use, thisArg: typeof app, args: Parameters<typeof app.use>): ReturnType<typeof app.use> {
29 const [first, ...rest] = args as [unknown, ...MiddlewareHandler[]];
30
31 if (typeof first === 'string') {
32 const wrappedHandlers = rest.map(handler => wrapMiddlewareWithSpan(handler));
33 return Reflect.apply(target, thisArg, [first, ...wrappedHandlers]);
34 }
35
36 const allHandlers = [first as MiddlewareHandler, ...rest].map(handler => wrapMiddlewareWithSpan(handler));
37 return Reflect.apply(target, thisArg, allHandlers);
38 },
39 });
40}
41
42/**
43 * Patches HTTP method class fields (get, post, put, delete, options, patch, all) to instrument inline middleware at registration time.

Callers 2

applyPatchesFunction · 0.90

Calls 3

hasMethod · 0.65
logMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected