Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Latest commit

 

History

History
37 lines (29 loc) · 936 Bytes

File metadata and controls

37 lines (29 loc) · 936 Bytes

Home > fastify-metrics > _default

_default variable

Metric plugin

Signature:

_default: import('fastify').FastifyPluginAsync<
  Partial<IMetricsPluginOptions>,
  import('fastify').RawServerDefault,
  import('fastify').FastifyTypeProviderDefault
>;

Example

    import fastify from 'fastify'
    import fastifyMetrics, { IMetricsPluginOptions } from fastify-metrics

    const options: IMetricsPluginOptions = { endpoint: '/metrics' }
    fastify()
     .register(fastifyMetrics, options)
     .get('/foo', (request, reply) => {
        reply.code(200);
        const delay = Math.random() * 10000;
        setTimeout(() => {
          reply.send({ id, delay });
        }, delay);
     })
     .ready()
     .listen(3000)