@thisisagile/easy-express 8.44.5 → 8.44.9
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,7 +10,7 @@ const toResponse = (status, errors = []) => ({
|
|
|
10
10
|
const toBody = ({ origin, options }) => {
|
|
11
11
|
return ((0, easy_1.choose)(origin)
|
|
12
12
|
.type(AuthError_1.isAuthError, ae => toResponse((0, easy_1.toHttpStatus)(ae.status), [(0, easy_1.toResult)(ae.message)]))
|
|
13
|
-
.
|
|
13
|
+
.type(easy_1.isDoesNotExist, e => toResponse(options?.onNotFound ?? easy_1.HttpStatus.NotFound, [(0, easy_1.toResult)(e.reason ?? e.message)]))
|
|
14
14
|
.type(easy_1.isError, e => toResponse(easy_1.HttpStatus.InternalServerError, [(0, easy_1.toResult)(e.message)]))
|
|
15
15
|
.type(easy_1.isResults, r => toResponse(options?.onError ?? easy_1.HttpStatus.BadRequest, r.results))
|
|
16
16
|
.type(easy_1.isResponse, r => toResponse(easy_1.HttpStatus.InternalServerError, r.body.error?.errors))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../src/express/ErrorHandler.ts"],"names":[],"mappings":";;;AACA,2CAA0C;AAC1C,4CAmB2B;AAE3B,MAAM,UAAU,GAAG,CAAC,MAAkB,EAAE,SAAmB,EAAE,EAAY,EAAE,CAAC,CAAC;IAC3E,MAAM;IACN,IAAI,EAAE,WAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC;CACnC,CAAC,CAAC;AAEH,MAAM,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,OAAO,EAAmB,EAAY,EAAE;IAChE,OAAO,CACL,IAAA,aAAM,EAAgB,MAAM,CAAC;SAC1B,IAAI,CAAC,uBAAW,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,IAAA,mBAAY,EAAC,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,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AAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;SAC5G,OAAO,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC;SACvB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC;AARW,QAAA,KAAK,SAQhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thisisagile/easy-express",
|
|
3
|
-
"version": "8.44.
|
|
3
|
+
"version": "8.44.9",
|
|
4
4
|
"description": "Straightforward library for building domain-driven microservice architectures",
|
|
5
5
|
"author": "Sander Hoogendoorn",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@thisisagile/easy-test": "8.44.
|
|
34
|
+
"@thisisagile/easy-test": "8.44.9",
|
|
35
35
|
"@types/cls-hooked": "^4.3.3",
|
|
36
36
|
"@types/form-urlencoded": "^4.4.0",
|
|
37
37
|
"@types/jsonwebtoken": "^8.5.8",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/validator": "^13.7.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@thisisagile/easy": "8.44.
|
|
44
|
+
"@thisisagile/easy": "8.44.9",
|
|
45
45
|
"@types/express": "^4.17.13",
|
|
46
46
|
"cls-hooked": "^4.2.2",
|
|
47
47
|
"express": "^4.17.1",
|
|
@@ -4,8 +4,8 @@ import {
|
|
|
4
4
|
asString,
|
|
5
5
|
choose,
|
|
6
6
|
ctx,
|
|
7
|
-
Exception,
|
|
8
7
|
HttpStatus,
|
|
8
|
+
isDoesNotExist,
|
|
9
9
|
isError,
|
|
10
10
|
isException,
|
|
11
11
|
isResponse,
|
|
@@ -30,10 +30,7 @@ const toBody = ({ origin, options }: OriginatedError): Response => {
|
|
|
30
30
|
return (
|
|
31
31
|
choose<Response, any>(origin)
|
|
32
32
|
.type(isAuthError, ae => toResponse(toHttpStatus(ae.status), [toResult(ae.message)]))
|
|
33
|
-
.
|
|
34
|
-
o => Exception.DoesNotExist.equals(o),
|
|
35
|
-
(o: Exception) => toResponse(options?.onNotFound ?? HttpStatus.NotFound, [toResult(o.reason ?? o.message)])
|
|
36
|
-
)
|
|
33
|
+
.type(isDoesNotExist, e => toResponse(options?.onNotFound ?? HttpStatus.NotFound, [toResult(e.reason ?? e.message)]))
|
|
37
34
|
// This service breaks with an error
|
|
38
35
|
.type(isError, e => toResponse(HttpStatus.InternalServerError, [toResult(e.message)]))
|
|
39
36
|
// This service fails
|