Comparing version 1.3.1 to 1.4.0
@@ -5,2 +5,10 @@ # Changelog | ||
## [1.4.0][] - 2021-02-17 | ||
- Fix error passing to client side | ||
- Call application.invoke to execute methods with schema validation | ||
- Don't pass context to `application.getMethod` | ||
- Pass context to application.invoke | ||
- Now proc is a struct, not just method with injected context | ||
## [1.3.1][] - 2021-02-09 | ||
@@ -42,3 +50,4 @@ | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v1.3.1...HEAD | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v1.4.0...HEAD | ||
[1.4.0]: https://github.com/metarhia/metacom/compare/v1.3.1...v1.4.0 | ||
[1.3.1]: https://github.com/metarhia/metacom/compare/v1.3.0...v1.3.1 | ||
@@ -45,0 +54,0 @@ [1.3.0]: https://github.com/metarhia/metacom/compare/v1.2.0...v1.3.0 |
@@ -146,11 +146,9 @@ 'use strict'; | ||
error(code, err, callId = err) { | ||
error(code, err, callId) { | ||
const { req, res, connection, ip, application } = this; | ||
const { url, method } = req; | ||
const status = http.STATUS_CODES[code]; | ||
if (typeof err === 'number') err = undefined; | ||
const reason = err ? err.stack : status; | ||
const reason = err !== null ? err.stack : status; | ||
application.console.error(`${ip}\t${method}\t${url}\t${code}\t${reason}`); | ||
const { Error } = this.application; | ||
const message = err instanceof Error ? err.message : status; | ||
const message = status || err.message; | ||
const error = { message, code }; | ||
@@ -195,3 +193,3 @@ if (connection) { | ||
} catch { | ||
this.error(504, callId); | ||
this.error(504, null, callId); | ||
return; | ||
@@ -202,12 +200,12 @@ } | ||
const context = session ? session.context : { client }; | ||
const proc = application.getMethod(iname, ver, methodName, context); | ||
const proc = application.getMethod(iname, ver, methodName); | ||
if (!proc) { | ||
this.error(404, callId); | ||
this.error(404, null, callId); | ||
return; | ||
} | ||
if (!this.session && proc.access !== 'public') { | ||
this.error(403, callId); | ||
this.error(403, null, callId); | ||
return; | ||
} | ||
const result = await proc.method(args); | ||
const result = await application.invoke(context, proc, args); | ||
if (result instanceof Error) { | ||
@@ -214,0 +212,0 @@ this.error(result.code, result, callId); |
{ | ||
"name": "metacom", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -57,3 +57,3 @@ "description": "Communication protocol for Metarhia stack with rpc, events, binary streams, memory and db access", | ||
"devDependencies": { | ||
"eslint": "^7.19.0", | ||
"eslint": "^7.20.0", | ||
"eslint-config-metarhia": "^7.0.1", | ||
@@ -60,0 +60,0 @@ "eslint-config-prettier": "^7.2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29184
759