1.0.1 • Published 2 years ago

ti-metrics v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

ti-metrics

usage

  • install package
    yarn add ti-metrics

    //local
    yarn add ti-metrics@file:$PATH/ti-metrics
  • build package
    yarn build
  • usage
# main.ts
import tiMetrics from 'ti-metrics';

tiMetrics.Metrics.getInstance().setup('appName');

  app.useGlobalInterceptors(
    new tiMetrics.LoggingHttpInterceptor(
      ['password', 'cellphone'],
      ['/metrics'],
    ),
  );

#api.module.ts

import tiMetrics from 'ti-metrics';
controllers: [tiMetrics.HttpMetricsController],


#custom log
tiMetrics.Logger.log({
        headers: request.headers,
        request: request.body,
        response: {
          statusCode: 401,
          message: 'Unauthorized',
        },
        url: request.originalUrl,
        statusCode: 401,
        ip,
        method,
        time: t1 - t0,
        route: path,
        params,
        query,
        memory,
});