@vasrefil/api-toolkit 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,12 @@
1
1
  import { ServiceRespI } from '../interfaces/interface';
2
- declare class AirbrakeLogger {
3
- private airbrake;
4
- constructor(projectId: string, projectKey: string);
5
- logRequestError(serviceResponse: ServiceRespI): void;
6
- logError(error: any, params: any, route: any): void;
7
- getAirbrakeInstance(): any;
8
- getAirbrakeExpress(): any;
9
- }
10
- export { AirbrakeLogger };
2
+ declare const airbrakeExpress: any;
3
+ declare const airbrake: any;
4
+ declare const airbrake_request_logger: (dto: {
5
+ serviceResponse: ServiceRespI;
6
+ }) => void;
7
+ declare const airtbrake_error_logger: (dto: {
8
+ error: any;
9
+ params: any;
10
+ route: any;
11
+ }) => void;
12
+ export { airbrake, airbrakeExpress, airbrake_request_logger, airtbrake_error_logger };
@@ -3,56 +3,49 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.AirbrakeLogger = void 0;
6
+ exports.airtbrake_error_logger = exports.airbrake_request_logger = exports.airbrakeExpress = exports.airbrake = void 0;
7
7
  const env_1 = __importDefault(require("../env"));
8
8
  const Airbrake = require('@airbrake/node');
9
9
  const airbrakeExpress = require('@airbrake/node/dist/instrumentation/express');
10
+ exports.airbrakeExpress = airbrakeExpress;
10
11
  const json_stringify_safe = require('json-stringify-safe');
11
- class AirbrakeLogger {
12
- constructor(projectId, projectKey) {
13
- this.airbrake = new Airbrake.Notifier({
14
- projectId: projectId,
15
- projectKey: projectKey,
16
- environment: `${env_1.default.NODE_ENV}`
12
+ const airbrake = new Airbrake.Notifier({
13
+ projectId: env_1.default.AIRBRAKE.PROJECT_ID,
14
+ projectKey: env_1.default.AIRBRAKE.PROJECT_KEY,
15
+ environment: `${env_1.default.NODE_ENV}`
16
+ });
17
+ exports.airbrake = airbrake;
18
+ const airbrake_request_logger = (dto) => {
19
+ try {
20
+ const { request, error, data, message, actionType } = dto.serviceResponse;
21
+ const dataErr = data ? json_stringify_safe(data) : null;
22
+ const errorErr = error ? json_stringify_safe(error, null) : null;
23
+ const messageErr = message ? json_stringify_safe(message) : null;
24
+ const error_ = messageErr || errorErr || dataErr;
25
+ const actionType_ = actionType || 'App Error';
26
+ const body = request && request.body ? request.body : 'no body';
27
+ const url = request && request.url ? request.url : 'no url';
28
+ airbrake.notify({
29
+ error: error_,
30
+ params: { url, body, actionType: actionType_ },
31
+ route: url
17
32
  });
18
33
  }
19
- logRequestError(serviceResponse) {
20
- try {
21
- const { request, error, data, message, actionType } = serviceResponse;
22
- const dataErr = data ? json_stringify_safe(data) : null;
23
- const errorErr = error ? json_stringify_safe(error, null) : null;
24
- const messageErr = message ? json_stringify_safe(message) : null;
25
- const error_ = messageErr || errorErr || dataErr;
26
- const actionType_ = actionType || 'App Error';
27
- const body = request && request.body ? request.body : 'no body';
28
- const url = request && request.url ? request.url : 'no url';
29
- this.airbrake.notify({
30
- error: error_,
31
- params: { url, body, actionType: actionType_ },
32
- route: url
33
- });
34
- }
35
- catch (error) {
36
- this.airbrake.notify(error);
37
- }
34
+ catch (error) {
35
+ airbrake.notify(error);
38
36
  }
39
- logError(error, params, route) {
40
- try {
41
- this.airbrake.notify({
42
- error: json_stringify_safe(error, null),
43
- params,
44
- route
45
- });
46
- }
47
- catch (error) {
48
- this.airbrake.notify(error);
49
- }
50
- }
51
- getAirbrakeInstance() {
52
- return this.airbrake;
37
+ };
38
+ exports.airbrake_request_logger = airbrake_request_logger;
39
+ const airtbrake_error_logger = (dto) => {
40
+ try {
41
+ airbrake.notify({
42
+ error: json_stringify_safe(dto.error, null),
43
+ params: dto.params,
44
+ route: dto.route
45
+ });
53
46
  }
54
- getAirbrakeExpress() {
55
- return airbrakeExpress;
47
+ catch (error) {
48
+ airbrake.notify(error);
56
49
  }
57
- }
58
- exports.AirbrakeLogger = AirbrakeLogger;
50
+ };
51
+ exports.airtbrake_error_logger = airtbrake_error_logger;
@@ -0,0 +1 @@
1
+ export * from './airbrake';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./airbrake"), exports);
@@ -1,4 +1,5 @@
1
1
  export * from './controllers';
2
2
  export * from './helpers';
3
3
  export * from './utilities';
4
+ export * from './app-middlewares';
4
5
  export { setEnvs } from './env';
@@ -18,5 +18,6 @@ exports.setEnvs = void 0;
18
18
  __exportStar(require("./controllers"), exports);
19
19
  __exportStar(require("./helpers"), exports);
20
20
  __exportStar(require("./utilities"), exports);
21
+ __exportStar(require("./app-middlewares"), exports);
21
22
  var env_1 = require("./env");
22
23
  Object.defineProperty(exports, "setEnvs", { enumerable: true, get: function () { return env_1.setEnvs; } });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vasrefil/api-toolkit",
3
3
  "description": "This is Vasrefil API toolkit",
4
- "version": "1.0.12",
4
+ "version": "1.0.13",
5
5
  "author": "Sodiq Alabi",
6
6
  "main": "dist/public-api.js",
7
7
  "types": "dist/public-api.d.ts",