Skip to content

Commit b5e9317

Browse files
committed
refactor: cleanup plugin fn
1 parent 1131a7b commit b5e9317

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

src/tracing.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export type HandlerType = "middleware" | "route";
1111

1212
export interface H3THandlerTracePayload {
1313
event: H3Event;
14-
route?: string;
1514
type: HandlerType;
1615
}
1716

@@ -26,8 +25,8 @@ export interface TracingPluginOptions {
2625
/**
2726
* Enables tracing for H3 apps.
2827
*/
29-
export const tracingPlugin = (traceOpts?: TracingPluginOptions): H3Plugin => {
30-
return definePlugin((h3) => {
28+
export const tracingPlugin: (traceOpts?: TracingPluginOptions) => H3Plugin =
29+
definePlugin((h3, traceOpts?: TracingPluginOptions) => {
3130
const { tracingChannel } =
3231
globalThis.process.getBuiltinModule?.("diagnostics_channel") ?? {};
3332

@@ -45,7 +44,7 @@ export const tracingPlugin = (traceOpts?: TracingPluginOptions): H3Plugin => {
4544

4645
const wrappedMiddleware: MaybeTracedMiddleware = (...args) => {
4746
return requestHandlerChannel.tracePromise(
48-
async () => await middleware(...args),
47+
async () => middleware(...args),
4948
{
5049
event: args[0],
5150
type: "middleware",
@@ -64,7 +63,7 @@ export const tracingPlugin = (traceOpts?: TracingPluginOptions): H3Plugin => {
6463

6564
const wrappedHandler: MaybeTracedEventHandler = (...args) => {
6665
return requestHandlerChannel.tracePromise(
67-
async () => await handler(...args),
66+
async () => handler(...args),
6867
{
6968
event: args[0],
7069
type: "route",
@@ -131,5 +130,4 @@ export const tracingPlugin = (traceOpts?: TracingPluginOptions): H3Plugin => {
131130
// TODO: Trace mount
132131

133132
return h3;
134-
})();
135-
};
133+
});

0 commit comments

Comments
 (0)