Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@based/server

Package Overview
Dependencies
Maintainers
1
Versions
112
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@based/server - npm Package Compare versions

Comparing version 6.4.0 to 6.4.1

2

dist/channel/start.js

@@ -73,3 +73,3 @@ "use strict";

channel.closeFunction = client
.channel(channel.name, channel.payload)
.channel(spec.relay.target ?? channel.name, channel.payload)
.subscribe((msg) => {

@@ -76,0 +76,0 @@ updateChannelListener(server, channel, msg);

@@ -8,2 +8,42 @@ "use strict";

const httpFunction = async (route, spec, server, ctx, payload) => {
if (spec.relay) {
const client = server.clients[spec.relay.client];
if (!client) {
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionError, {
err: new Error('Cannot find client ' + spec.relay),
route,
});
return;
}
client
.call(spec.relay.target ?? spec.name, payload)
.then(async (result) => {
if (!ctx.session) {
return;
}
if (spec.httpResponse) {
const send = (responseData, headers, status) => {
if (!ctx.session) {
return;
}
if (!status) {
(0, sendHttpResponse_1.sendHttpResponse)(ctx, responseData, headers);
}
else {
(0, sendHttpResponse_1.sendHttpResponse)(ctx, responseData, headers, typeof status === 'string' ? status : String(status));
}
};
await spec.httpResponse(server.client, payload, result, send, ctx);
return;
}
(0, sendHttpResponse_1.sendHttpResponse)(ctx, result);
})
.catch((err) => {
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionError, {
err,
route,
});
});
return;
}
spec

@@ -10,0 +50,0 @@ .fn(server.client, payload, ctx)

@@ -25,3 +25,3 @@ "use strict";

client
.call(spec.name, payload)
.call(spec.relay.target ?? spec.name, payload)
.then(async (v) => {

@@ -28,0 +28,0 @@ ctx.session?.ws.send((0, protocol_1.encodeFunctionResponse)(requestId, (0, protocol_1.valueToBuffer)(v)), true, false);

@@ -34,3 +34,3 @@ "use strict";

}
(0, relay_1.relay)(server, obs, client, update);
(0, relay_1.relay)(server, spec.relay, obs, client, update);
}

@@ -37,0 +37,0 @@ else {

import { ObservableUpdateFunction } from '@based/functions';
import { BasedServer } from '../../server';
import { ActiveObservable } from '../types';
export declare const relay: (server: BasedServer, obs: ActiveObservable, client: any, update: ObservableUpdateFunction) => void;
export declare const relay: (server: BasedServer, relay: {
target?: string;
client: string;
}, obs: ActiveObservable, client: any, update: ObservableUpdateFunction) => void;

@@ -6,5 +6,5 @@ "use strict";

// this has to be super optmized!
const relay = (server, obs, client, update) => {
const relay = (server, relay, obs, client, update) => {
obs.closeFunction = client
.query(obs.name, obs.payload)
.query(relay.target ?? obs.name, obs.payload)
.subscribe(update, (err) => {

@@ -11,0 +11,0 @@ (0, error_1.errorListener)(server, obs, err);

{
"name": "@based/server",
"version": "6.4.0",
"version": "6.4.1",
"license": "MIT",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc