@voiceflow/backend-utils
Advanced tools
@@ -1,3 +0,2 @@ | ||
| import Logger from '@voiceflow/logger'; | ||
| declare const log: Logger; | ||
| declare const log: import("pino").Logger<never>; | ||
| export default log; |
+5
-6
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const logger_1 = __importDefault(require("@voiceflow/logger")); | ||
| const options = ['local', 'test'].includes(process.env.NODE_ENV) ? { level: 'info', pretty: true } : {}; | ||
| const log = new logger_1.default(options); | ||
| const logger_1 = require("@voiceflow/logger"); | ||
| const log = (0, logger_1.createLogger)({ | ||
| format: logger_1.LogFormat.INLINE, | ||
| level: process.env.LOG_LEVEL ?? logger_1.LogLevel.INFO, | ||
| }); | ||
| exports.default = log; | ||
| //# sourceMappingURL=logger.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;;;AAAA,+DAAuC;AAEvC,MAAM,OAAO,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAa,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAEhH,MAAM,GAAG,GAAG,IAAI,gBAAM,CAAC,OAAO,CAAC,CAAC;AAEhC,kBAAe,GAAG,CAAC"} | ||
| {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;AAAA,8CAAsE;AAEtE,MAAM,GAAG,GAAG,IAAA,qBAAY,EAAC;IACvB,MAAM,EAAE,kBAAS,CAAC,MAAM;IACxB,KAAK,EAAG,OAAO,CAAC,GAAG,CAAC,SAAsB,IAAI,iBAAQ,CAAC,IAAI;CAC5D,CAAC,CAAC;AAEH,kBAAe,GAAG,CAAC"} |
@@ -1,2 +0,1 @@ | ||
| export * from './exception'; | ||
| export * from './rateLimit'; |
@@ -17,4 +17,3 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __exportStar(require("./exception"), exports); | ||
| __exportStar(require("./rateLimit"), exports); | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,8CAA4B"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middlewares/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B"} |
@@ -116,6 +116,5 @@ "use strict"; | ||
| */ | ||
| // eslint-disable-next-line sonarjs/cognitive-complexity | ||
| static errorResponse(error, codeOverride, req) { | ||
| if (error && error.isAxiosError) { | ||
| logger_1.default.error(`@backend-utils:errorResponse - error:axios:${JSON.stringify(ResponseBuilder.getAxiosError(error))}`); | ||
| logger_1.default.error(`@backend-utils:errorResponse - error:axios %o`, ResponseBuilder.getAxiosError(error)); | ||
| } | ||
@@ -146,3 +145,3 @@ if (!(error instanceof Error)) { | ||
| // eslint-disable-next-line sonarjs/no-nested-template-literals | ||
| `500+ error: ${req?.originalUrl} ${req?.user ? ` User ID: ${req?.user.id}` : ''} ${error.stack} ${error.data ? JSON.stringify(error.data) : ''}`); | ||
| `500+ error: ${req?.originalUrl} ${req?.user ? ` User ID: ${req?.user.id}` : ''} ${error.stack} %o`, error.data); | ||
| } | ||
@@ -149,0 +148,0 @@ return response; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"responseBuilder.js","sourceRoot":"","sources":["../src/responseBuilder.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAuC;AAGvC,oEAAsD;AAEtD,iCAAiC;AAEjC,sDAA2B;AAG3B,MAAM,e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CAAC,UAAU,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;aAC7D;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,GAAG,eAAe,CAAC,aAAa,CAAC,GAAG,EAAE,mBAAmB,EAAE,GAAG,CAAC,CAAC;aACvE;YAED,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE;gBACpB,IAAI,UAAU,EAAE;oBACd,sFAAsF;oBACrF,UAAyB,EAAE,CAAC;iBAC9B;qBAAM;oBACL,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAc,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;iBACrD;aACF;QACH,CAAC,CAAQ,CAAC;IACZ,CAAC;CAEF;AAED,kBAAe,eAAe,CAAC"} |
+3
-2
| { | ||
| "name": "@voiceflow/backend-utils", | ||
| "description": "Junk drawer of utility functions", | ||
| "version": "4.8.5", | ||
| "version": "5.0.0", | ||
| "author": "Voiceflow", | ||
@@ -16,3 +16,2 @@ "bugs": { | ||
| "@types/http-errors": "^1.8.2", | ||
| "@voiceflow/logger": "1.6.1", | ||
| "@voiceflow/verror": "1.1.3", | ||
@@ -49,2 +48,3 @@ "chai": "^4.3.4", | ||
| "@voiceflow/git-branch-check": "1.4.0", | ||
| "@voiceflow/logger": "2.2.0", | ||
| "@voiceflow/prettier-config": "1.2.1", | ||
@@ -86,2 +86,3 @@ "@voiceflow/tsconfig": "1.4.3", | ||
| "@voiceflow/common": "^7.2.0", | ||
| "@voiceflow/logger": "^2", | ||
| "express-validator": "^6.3.0", | ||
@@ -88,0 +89,0 @@ "ioredis": "^4.28.5", |
| import { GaxiosError } from 'gaxios'; | ||
| import type { ExceptionFormatter } from '../types'; | ||
| export declare const formatGaxiosError: ExceptionFormatter<GaxiosError>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.formatGaxiosError = void 0; | ||
| const formatGaxiosError = (err) => { | ||
| return { | ||
| statusCode: err.response?.status, | ||
| name: 'GaxiosError', | ||
| message: err.message, | ||
| details: { | ||
| code: err.code, | ||
| statusText: err.response?.statusText, | ||
| }, | ||
| }; | ||
| }; | ||
| exports.formatGaxiosError = formatGaxiosError; | ||
| //# sourceMappingURL=gaxiosError.js.map |
| {"version":3,"file":"gaxiosError.js","sourceRoot":"","sources":["../../../../src/middlewares/exception/formatters/gaxiosError.ts"],"names":[],"mappings":";;;AAIO,MAAM,iBAAiB,GAAoC,CAAC,GAAG,EAAE,EAAE;IACxE,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,QAAQ,EAAE,MAAM;QAChC,IAAI,EAAE,aAAa;QACnB,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,OAAO,EAAE;YACP,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,UAAU,EAAE,GAAG,CAAC,QAAQ,EAAE,UAAU;SACrC;KACF,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B"} |
| import { HttpError } from 'http-errors'; | ||
| import type { ExceptionFormatter } from '../types'; | ||
| export declare const formatHttpError: ExceptionFormatter<HttpError>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.formatHttpError = void 0; | ||
| const formatHttpError = (err) => { | ||
| return { | ||
| statusCode: err.statusCode, | ||
| name: err.name, | ||
| message: err.message, | ||
| }; | ||
| }; | ||
| exports.formatHttpError = formatHttpError; | ||
| //# sourceMappingURL=httpError.js.map |
| {"version":3,"file":"httpError.js","sourceRoot":"","sources":["../../../../src/middlewares/exception/formatters/httpError.ts"],"names":[],"mappings":";;;AAIO,MAAM,eAAe,GAAkC,CAAC,GAAG,EAAE,EAAE;IACpE,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,eAAe,mBAM1B"} |
| import type { ExceptionFormat } from '../types'; | ||
| export declare const formatError: (err: unknown) => ExceptionFormat; | ||
| export declare const mergeExceptionResult: (baseException: ExceptionFormat, exception: Partial<ExceptionFormat>) => { | ||
| statusCode: number; | ||
| name: string; | ||
| message: string; | ||
| details?: Record<string, any> | undefined; | ||
| }; |
| "use strict"; | ||
| var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| var desc = Object.getOwnPropertyDescriptor(m, k); | ||
| if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
| desc = { enumerable: true, get: function() { return m[k]; } }; | ||
| } | ||
| Object.defineProperty(o, k2, desc); | ||
| }) : (function(o, m, k, k2) { | ||
| if (k2 === undefined) k2 = k; | ||
| o[k2] = m[k]; | ||
| })); | ||
| var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
| Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
| }) : function(o, v) { | ||
| o["default"] = v; | ||
| }); | ||
| var __importStar = (this && this.__importStar) || function (mod) { | ||
| if (mod && mod.__esModule) return mod; | ||
| var result = {}; | ||
| if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
| __setModuleDefault(result, mod); | ||
| return result; | ||
| }; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.mergeExceptionResult = exports.formatError = void 0; | ||
| const verror_1 = __importDefault(require("@voiceflow/verror")); | ||
| const Guards = __importStar(require("../../../guards")); | ||
| const gaxiosError_1 = require("./gaxiosError"); | ||
| const httpError_1 = require("./httpError"); | ||
| const jsError_1 = require("./jsError"); | ||
| const vError_1 = require("./vError"); | ||
| const formatError = (err) => { | ||
| let exception = { | ||
| statusCode: verror_1.default.HTTP_STATUS.INTERNAL_SERVER_ERROR, | ||
| name: 'UnknownError', | ||
| message: 'Unknown error', | ||
| }; | ||
| if (Guards.isVError(err)) | ||
| exception = (0, exports.mergeExceptionResult)(exception, (0, vError_1.formatVError)(err)); | ||
| else if (Guards.isHttpError(err)) | ||
| exception = (0, exports.mergeExceptionResult)(exception, (0, httpError_1.formatHttpError)(err)); | ||
| else if (Guards.isGaxiosError(err)) | ||
| exception = (0, exports.mergeExceptionResult)(exception, (0, gaxiosError_1.formatGaxiosError)(err)); | ||
| else if (Guards.isJavascriptError(err)) | ||
| exception = (0, exports.mergeExceptionResult)(exception, (0, jsError_1.formatJavascriptError)(err)); | ||
| return exception; | ||
| }; | ||
| exports.formatError = formatError; | ||
| const mergeExceptionResult = (baseException, exception) => ({ | ||
| ...baseException, | ||
| ...exception, | ||
| }); | ||
| exports.mergeExceptionResult = mergeExceptionResult; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/middlewares/exception/formatters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+DAAuC;AAEvC,wDAA0C;AAE1C,+CAAkD;AAClD,2CAA8C;AAC9C,uCAAkD;AAClD,qCAAwC;AAEjC,MAAM,WAAW,GAAG,CAAC,GAAY,EAAmB,EAAE;IAC3D,IAAI,SAAS,GAAoB;QAC/B,UAAU,EAAE,gBAAM,CAAC,WAAW,CAAC,qBAAqB;QACpD,IAAI,EAAE,cAAc;QACpB,OAAO,EAAE,eAAe;KACzB,CAAC;IAEF,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,SAAS,GAAG,IAAA,4BAAoB,EAAC,SAAS,EAAE,IAAA,qBAAY,EAAC,GAAG,CAAC,CAAC,CAAC;SACpF,IAAI,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC;QAAE,SAAS,GAAG,IAAA,4BAAoB,EAAC,SAAS,EAAE,IAAA,2BAAe,EAAC,GAAG,CAAC,CAAC,CAAC;SAC/F,IAAI,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC;QAAE,SAAS,GAAG,IAAA,4BAAoB,EAAC,SAAS,EAAE,IAAA,+BAAiB,EAAC,GAAG,CAAC,CAAC,CAAC;SACnG,IAAI,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC;QAAE,SAAS,GAAG,IAAA,4BAAoB,EAAC,SAAS,EAAE,IAAA,+BAAqB,EAAC,GAAG,CAAC,CAAC,CAAC;IAEhH,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAbW,QAAA,WAAW,eAatB;AAEK,MAAM,oBAAoB,GAAG,CAAC,aAA8B,EAAE,SAAmC,EAAE,EAAE,CAAC,CAAC;IAC5G,GAAG,aAAa;IAChB,GAAG,SAAS;CACb,CAAC,CAAC;AAHU,QAAA,oBAAoB,wBAG9B"} |
| import type { ExceptionFormatter } from '../types'; | ||
| export declare const formatJavascriptError: ExceptionFormatter<Error>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.formatJavascriptError = void 0; | ||
| const formatJavascriptError = (err) => { | ||
| return { | ||
| name: err.name, | ||
| message: err.message, | ||
| }; | ||
| }; | ||
| exports.formatJavascriptError = formatJavascriptError; | ||
| //# sourceMappingURL=jsError.js.map |
| {"version":3,"file":"jsError.js","sourceRoot":"","sources":["../../../../src/middlewares/exception/formatters/jsError.ts"],"names":[],"mappings":";;;AAEO,MAAM,qBAAqB,GAA8B,CAAC,GAAG,EAAE,EAAE;IACtE,OAAO;QACL,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC,CAAC;AALW,QAAA,qBAAqB,yBAKhC"} |
| import VError from '@voiceflow/verror'; | ||
| import type { ExceptionFormatter } from '../types'; | ||
| export declare const formatVError: ExceptionFormatter<VError>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.formatVError = void 0; | ||
| const formatVError = (err) => { | ||
| return { | ||
| statusCode: err.code, | ||
| name: err.name, | ||
| message: err.message, | ||
| }; | ||
| }; | ||
| exports.formatVError = formatVError; | ||
| //# sourceMappingURL=vError.js.map |
| {"version":3,"file":"vError.js","sourceRoot":"","sources":["../../../../src/middlewares/exception/formatters/vError.ts"],"names":[],"mappings":";;;AAIO,MAAM,YAAY,GAA+B,CAAC,GAAG,EAAE,EAAE;IAC9D,OAAO;QACL,UAAU,EAAE,GAAG,CAAC,IAAI;QACpB,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,OAAO,EAAE,GAAG,CAAC,OAAO;KACrB,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,YAAY,gBAMvB"} |
| import type { NextFunction, Request, Response } from 'express'; | ||
| import { AbstractMiddleware } from '../../types'; | ||
| export declare class ExceptionMiddleware extends AbstractMiddleware<never, never> { | ||
| constructor(); | ||
| handleError(err: unknown, req: Request, res: Response, _next: NextFunction): void; | ||
| } |
| "use strict"; | ||
| var __importDefault = (this && this.__importDefault) || function (mod) { | ||
| return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.ExceptionMiddleware = void 0; | ||
| const logger_1 = __importDefault(require("../../logger")); | ||
| const types_1 = require("../../types"); | ||
| const formatters_1 = require("./formatters"); | ||
| class ExceptionMiddleware extends types_1.AbstractMiddleware { | ||
| constructor() { | ||
| super(undefined, undefined); | ||
| } | ||
| handleError(err, req, res, _next) { | ||
| try { | ||
| logger_1.default.error(`Exception formatter (pre) ${JSON.stringify(err)}`); | ||
| const { statusCode, ...body } = (0, formatters_1.formatError)(err); | ||
| const error = { | ||
| ...body, | ||
| requestID: req.id?.toString(), | ||
| }; | ||
| logger_1.default.error(`Exception formatter (post) ${JSON.stringify(error)}`); | ||
| res.status(statusCode).send(error); | ||
| } | ||
| catch { | ||
| res.status(500).send({ | ||
| error: err, | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| exports.ExceptionMiddleware = ExceptionMiddleware; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/middlewares/exception/index.ts"],"names":[],"mappings":";;;;;;AAEA,0DAA+B;AAC/B,uCAAiD;AACjD,6CAA2C;AAE3C,MAAa,mBAAoB,SAAQ,0BAAgC;IACvE;QACE,KAAK,CAAC,SAAkB,EAAE,SAAkB,CAAC,CAAC;IAChD,CAAC;IAEM,WAAW,CAAC,GAAY,EAAE,GAAY,EAAE,GAAa,EAAE,KAAmB;QAC/E,IAAI;YACF,gBAAG,CAAC,KAAK,CAAC,6BAA6B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAE9D,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,IAAA,wBAAW,EAAC,GAAG,CAAC,CAAC;YAEjD,MAAM,KAAK,GAAG;gBACZ,GAAG,IAAI;gBACP,SAAS,EAAE,GAAG,CAAC,EAAE,EAAE,QAAQ,EAAE;aAC9B,CAAC;YAEF,gBAAG,CAAC,KAAK,CAAC,8BAA8B,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;YAEjE,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpC;QAAC,MAAM;YACN,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;gBACnB,KAAK,EAAE,GAAG;aACX,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AAzBD,kDAyBC"} |
| export interface ExceptionFormat { | ||
| statusCode: number; | ||
| name: string; | ||
| message: string; | ||
| details?: Record<string, any>; | ||
| } | ||
| export declare type ExceptionFormatter<T> = (err: T) => Partial<ExceptionFormat>; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=types.js.map |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/middlewares/exception/types.ts"],"names":[],"mappings":""} |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3
-25%66430
-14.11%40
2.56%50
-29.58%930
-15.84%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed