diff --git a/dist/gateway-express.js b/dist/gateway-express.js index 438c6ec..277ffcb 100644 --- a/dist/gateway-express.js +++ b/dist/gateway-express.js @@ -49,7 +49,7 @@ function gateway_express(options) { } if (gateway$.next) { // Uses the default express error handler - return next(result.error ? result.out.error$ : undefined); + return next(result.error ? result.out : undefined); } // Should be last as final action else if ((_a = gateway$.redirect) === null || _a === void 0 ? void 0 : _a.location) { @@ -57,7 +57,7 @@ function gateway_express(options) { } if (result.error) { if ((_c = options.error) === null || _c === void 0 ? void 0 : _c.next) { - return next(result.error ? result.out.error$ : undefined); + return next(result.error ? result.out : undefined); } else { res.status(gateway$.status || 500); diff --git a/dist/gateway-express.js.map b/dist/gateway-express.js.map index 6e47070..5919d1f 100644 --- a/dist/gateway-express.js.map +++ b/dist/gateway-express.js.map @@ -1 +1 @@ -{"version":3,"file":"gateway-express.js","sourceRoot":"","sources":["../src/gateway-express.ts"],"names":[],"mappings":";AAAA,wDAAwD;;AAGxD,+BAA2B;AAsD3B,SAAS,eAAe,CAAY,OAA8B;IAChE,MAAM,MAAM,GAAQ,IAAI,CAAA;IAExB,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,CAAA;IAC7B,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAA;IAC1D,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,GAAG,UAAU,CAAC,CAAA;IAC5D,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,GAAG,IAAI,GAAG,YAAY,CAAC,CAAA;IAGhE,MAAM,CAAC,GAAG,CAAC,oCAAoC,EAAE;QAC/C,OAAO,EAAE,SAAS;QAClB,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,GAAG;QACtB,MAAM,EAAE,CAAC,KAAU,EAAE,GAAQ,EAA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AuD;QACvD,sBAAsB;QACtB,MAAM,OAAO,GAAG;YACd,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,IAAI;YACJ,IAAI,EAAE,QAAQ,KAAK,OAAO,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;SACxD,CAAA;QAED,GAAG,CAAC,IAAI,GAAG,OAAO,CAAA;QAElB,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IAChC,CAAC;IAGD,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,OAAO,EAAE;YACP,OAAO;YACP,IAAI;SACL;KACF,CAAA;AACH,CAAC;AAGD,mBAAmB;AACnB,eAAe,CAAC,QAAQ,GAAG;IACzB,IAAI,EAAE;QACJ,KAAK,EAAE;YACL,IAAI,EAAE,aAAa;SACpB;QACD,MAAM,EAAE,IAAA,WAAI,EAAC;YACX,MAAM,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI;YACjC,QAAQ,EAAE,IAAI;YACd,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACD,KAAK,EAAE;QACL,IAAI,EAAE,KAAK;KACZ;CACF,CAAA;AAGD,kBAAe,eAAe,CAAA;AAE9B,IAAI,WAAW,KAAK,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;IACpC,MAAM,CAAC,OAAO,GAAG,eAAe,CAAA;AAClC,CAAC"} \ No newline at end of file diff --git a/package.json b/package.json index 43d1c1b..56a98da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@seneca/gateway-express", - "version": "0.9.0", + "version": "0.10.0", "main": "dist/gateway-express.js", "type": "commonjs", "types": "dist/gateway-express.d.ts", @@ -40,7 +40,7 @@ "devDependencies": { "@seneca/maintain": "^0.1.0", "@types/jest": "^29.5.10", - "esbuild": "^0.19.7", + "esbuild": "^0.19.8", "esbuild-jest": "^0.5.0", "express": "^4.17.1", "jest": "^29.7.0", @@ -48,7 +48,7 @@ "typescript": "^5.3.2" }, "peerDependencies": { - "@seneca/gateway": ">=0.8.0", + "@seneca/gateway": ">=0.9.0", "express": ">=4", "seneca": ">=3", "seneca-promisify": ">=3" diff --git a/src/gateway-express.ts b/src/gateway-express.ts index bbb2938..2a6d152 100644 --- a/src/gateway-express.ts +++ b/src/gateway-express.ts @@ -118,7 +118,7 @@ function gateway_express(this: any, options: GatewayExpressOptions) { if (gateway$.next) { // Uses the default express error handler - return next(result.error ? result.out.error$ : undefined) + return next(result.error ? result.out : undefined) } // Should be last as final action @@ -128,7 +128,7 @@ function gateway_express(this: any, options: GatewayExpressOptions) { if (result.error) { if (options.error?.next) { - return next(result.error ? result.out.error$ : undefined) + return next(result.error ? result.out : undefined) } else { res.status(gateway$.status || 500) diff --git a/test/gateway-express.test.ts b/test/gateway-express.test.ts index 46361eb..bb67089 100644 --- a/test/gateway-express.test.ts +++ b/test/gateway-express.test.ts @@ -97,8 +97,6 @@ describe('gateway-express', () => { } await handler(req, res, (err: any, _req: any, _res: any, _next: any) => { - // console.log(err) - expect(err).toMatchObject({ name: 'Error', code: 'act_not_found', @@ -156,7 +154,7 @@ describe('gateway-express', () => { expect(responses.length).toEqual(1) - expect(responses[0].error$).toEqual({ + expect(responses[0]).toMatchObject({ code: 'act_not_found', name: 'Error' })