Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const build = (t: any) => {
const app = Fastify()
// fastify-plugin ensures that all decorators
// are exposed for testing purposes, this is
// different from the production setup
app.register(fp(App), config())
// tear down our app after we are done
t.tearDown(app.close.bind(app))
return app
}
reqPath &&
// Record as a static file only when the path starts with `prefix`.
reqPath.startsWith(prefix)
) {
ap.recordRequestPath(resStream.session, reqPath, true);
}
}
});
}
function noop() {}
// This type is probably not useful. Users probably want to call fp to
// instantiate the plugin specifically for their specific Http server, request
// and response types rather than using the union types like we do here.
export const staticServe = fp<
HttpServer,
RawRequest,
RawResponse,
AutoPushOptions
>(staticServeFn);
});
request.metrics.hist({
method: method || 'UNKNOWN',
route: routeId,
status_code: statusCode,
});
}
next();
});
}
fastify.decorate(pluginName, plugin);
next();
};
export = fastifyPlugin(fastifyMetricsPlugin, {
fastify: '>=2.0.0',
name: 'fastify-metrics',
});