Comparing version 1.8.2 to 2.0.0
@@ -5,2 +5,8 @@ # Changelog | ||
## [2.0.0][] - 2021-08-19 | ||
- Support GET requests and change calls: `hook` and `invoke` | ||
- Add `redirect` method to `Client` with delegation to `Channel` | ||
- Update dependencies | ||
## [1.8.2][] - 2021-08-06 | ||
@@ -133,3 +139,4 @@ | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v1.8.2...HEAD | ||
[unreleased]: https://github.com/metarhia/metacom/compare/v2.0.0...HEAD | ||
[2.0.0]: https://github.com/metarhia/metacom/compare/v1.8.1...v2.0.0 | ||
[1.8.2]: https://github.com/metarhia/metacom/compare/v1.8.1...v1.8.2 | ||
@@ -136,0 +143,0 @@ [1.8.1]: https://github.com/metarhia/metacom/compare/v1.8.0...v1.8.1 |
@@ -63,2 +63,6 @@ 'use strict'; | ||
redirect(location) { | ||
return channels.get(this).redirect(location); | ||
} | ||
get ip() { | ||
@@ -222,6 +226,6 @@ return channels.get(this).ip; | ||
async hook(router, interfaceName, methodName, args) { | ||
async hook(proc, interfaceName, methodName, args) { | ||
const { application, client, res } = this; | ||
const callId = -1; | ||
if (!router) { | ||
if (!proc) { | ||
this.error(404, null, callId); | ||
@@ -233,3 +237,3 @@ return; | ||
try { | ||
result = await router.invoke(context, { method: methodName, args }); | ||
result = await proc.invoke(context, { method: methodName, args }); | ||
} catch (err) { | ||
@@ -239,4 +243,6 @@ this.error(500, err, callId); | ||
const data = JSON.stringify(result); | ||
res.writeHead(200, { 'Content-Type': MIME_TYPES.json, ...HEADERS }); | ||
res.end(data); | ||
if (!res.writableEnded) { | ||
res.writeHead(200, { 'Content-Type': MIME_TYPES.json, ...HEADERS }); | ||
res.end(data); | ||
} | ||
const record = `${this.ip}\t${interfaceName}/${methodName}`; | ||
@@ -243,0 +249,0 @@ application.console.log(record); |
@@ -109,3 +109,3 @@ 'use strict'; | ||
} | ||
if (req.method !== 'POST') { | ||
if (req.url === '/api' && req.method !== 'POST') { | ||
channel.error(403); | ||
@@ -126,3 +126,3 @@ return; | ||
const hook = this.application.getHook(interfaceName); | ||
if (hook) channel.hook(hook.router, interfaceName, methodName, args); | ||
if (hook) channel.hook(hook, interfaceName, methodName, args); | ||
else channel.rpc(-1, interfaceName, methodName, args); | ||
@@ -129,0 +129,0 @@ }); |
{ | ||
"name": "metacom", | ||
"version": "1.8.2", | ||
"version": "2.0.0", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -57,6 +57,6 @@ "description": "Communication protocol for Metarhia stack with rpc, events, binary streams, memory and db access", | ||
"metautil": "^3.5.9", | ||
"ws": "^7.5.3" | ||
"ws": "^8.2.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^16.3.3", | ||
"@types/node": "^16.6.2", | ||
"@types/ws": "^7.4.7", | ||
@@ -66,3 +66,3 @@ "eslint": "^7.31.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-import": "^2.24.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
@@ -69,0 +69,0 @@ "metatests": "^0.7.2", |
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
34569
812