@alanszp/express-common-fn 6.0.3 → 6.1.0
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.
|
@@ -10,8 +10,8 @@ const defaultsOption = {
|
|
|
10
10
|
extraContext: {},
|
|
11
11
|
};
|
|
12
12
|
function commonErrorsHandler(loggerFn) {
|
|
13
|
-
const logger = loggerFn();
|
|
14
13
|
return function handleCommonErrors(error, res, baseLog, options) {
|
|
14
|
+
const logger = loggerFn();
|
|
15
15
|
const opts = Object.assign(Object.assign({}, defaultsOption), options);
|
|
16
16
|
const instanceLogger = logger.child(opts.extraContext);
|
|
17
17
|
if (error instanceof validations_1.ModelValidationError) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commonErrorsHandler.js","sourceRoot":"","sources":["../src/commonErrorsHandler.ts"],"names":[],"mappings":";;;AAAA,8CAA6C;AAC7C,4CAIyB;AAEzB,sDAA4D;AAE5D,qCAAgE;AAOhE,MAAM,cAAc,GAAuB;IACzC,cAAc,EAAE,GAAG;IACnB,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,SAAgB,mBAAmB,CAAC,QAAuB;IACzD,
|
|
1
|
+
{"version":3,"file":"commonErrorsHandler.js","sourceRoot":"","sources":["../src/commonErrorsHandler.ts"],"names":[],"mappings":";;;AAAA,8CAA6C;AAC7C,4CAIyB;AAEzB,sDAA4D;AAE5D,qCAAgE;AAOhE,MAAM,cAAc,GAAuB;IACzC,cAAc,EAAE,GAAG;IACnB,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,SAAgB,mBAAmB,CAAC,QAAuB;IACzD,OAAO,SAAS,kBAAkB,CAChC,KAAc,EACd,GAAa,EACb,OAAe,EACf,OAAqC;QAErC,MAAM,MAAM,GAAG,QAAQ,EAAE,CAAC;QAE1B,MAAM,IAAI,mCACL,cAAc,GACd,OAAO,CACX,CAAC;QACF,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI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B,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACjE;YACD,OAAO;SACR;QAED,cAAc,CAAC,KAAK,CAAC,GAAG,OAAO,gBAAgB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;QAC5D,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAA,mBAAS,EAAC,IAAI,4BAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC;AAvDD,kDAuDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alanszp/express-common-fn",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"description": "Alan's express function to handle common errors and format uniformly.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@alanszp/errors": "^6.0.0",
|
|
23
|
-
"@alanszp/express": "^6.0.
|
|
24
|
-
"@alanszp/logger": "^6.0.
|
|
23
|
+
"@alanszp/express": "^6.0.5",
|
|
24
|
+
"@alanszp/logger": "^6.0.5",
|
|
25
25
|
"@alanszp/validations": "^6.0.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
@@ -32,5 +32,5 @@
|
|
|
32
32
|
"@types/express": "^4.17.12",
|
|
33
33
|
"typeorm": "^0.2.34"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "ae299a391c8ff98c199e476a3405d39986652bd7"
|
|
36
36
|
}
|
|
@@ -20,14 +20,14 @@ const defaultsOption: CommonErrorOptions = {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export function commonErrorsHandler(loggerFn: () => ILogger) {
|
|
23
|
-
const logger = loggerFn();
|
|
24
|
-
|
|
25
23
|
return function handleCommonErrors(
|
|
26
24
|
error: unknown,
|
|
27
25
|
res: Response,
|
|
28
26
|
baseLog: string,
|
|
29
27
|
options?: Partial<CommonErrorOptions>
|
|
30
28
|
): void {
|
|
29
|
+
const logger = loggerFn();
|
|
30
|
+
|
|
31
31
|
const opts: CommonErrorOptions = {
|
|
32
32
|
...defaultsOption,
|
|
33
33
|
...options,
|