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

@silenteer/natsu

Package Overview
Dependencies
Maintainers
2
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@silenteer/natsu - npm Package Compare versions

Comparing version 1.0.36 to 1.0.37

215

dist/nats-client.js

@@ -38,123 +38,104 @@ "use strict";

Object.entries(registeredHandlers).forEach(([subject, { handler, injection: registeredInjection, middlewares }]) => {
const subcription = natsService.subscribe(subject);
(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
var _a, e_1, _b, _c;
try {
for (var _d = true, subcription_1 = tslib_1.__asyncValues(subcription), subcription_1_1; subcription_1_1 = yield subcription_1.next(), _a = subcription_1_1.done, !_a;) {
_c = subcription_1_1.value;
_d = false;
try {
const message = _c;
let data = message.data
? requestCodec.decode(message.data)
: undefined;
const handlerLogService = registeredInjection.logService;
let injection;
try {
injection = Object.assign(Object.assign({}, registeredInjection), { message,
natsService });
handlerLogService.info('Begin');
if (!data) {
handlerLogService.error('Incoming message has no data');
yield respond({
message,
request: data,
response: {
headers: data === null || data === void 0 ? void 0 : data.headers,
body: undefined,
code: 400,
},
injection,
onResponse: handler.response,
});
handlerLogService.info('End');
continue;
}
if (data.body) {
data = Object.assign(Object.assign({}, data), { body: data.body });
}
//#region Before
const beforeResult = yield before({
message,
data,
injection,
middlewares: middlewares.before,
});
if (beforeResult && beforeResult.code !== 'OK') {
handlerLogService.info('End');
continue;
}
else if (beforeResult) {
data = beforeResult.data;
injection = beforeResult.injection;
}
//#endregion
//#region Handle
let handleResult = yield handle({
message,
data,
injection,
handler,
});
if (handleResult && handleResult.code !== 'OK') {
handlerLogService.info('End');
continue;
}
//#endregion
//#region After
const afterResult = yield after({
message,
data,
result: handleResult,
injection,
middlewares: middlewares.after,
});
if (afterResult && afterResult.code !== 'OK') {
handlerLogService.info('End');
continue;
}
else if (afterResult) {
data = afterResult.data;
handleResult = afterResult.result;
injection = afterResult.injection;
}
//#endregion
yield respond({
message,
request: data,
response: {
headers: (handleResult === null || handleResult === void 0 ? void 0 : handleResult.headers)
? Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.headers), handleResult === null || handleResult === void 0 ? void 0 : handleResult.headers) : data === null || data === void 0 ? void 0 : data.headers,
code: (handleResult === null || handleResult === void 0 ? void 0 : handleResult.code) === 'OK' ? 200 : handleResult === null || handleResult === void 0 ? void 0 : handleResult.code,
body: handleResult === null || handleResult === void 0 ? void 0 : handleResult.body,
},
injection,
onResponse: handler.response,
});
handlerLogService.info('End');
}
catch (error) {
yield respondUnhandledError({
message,
data,
error,
injection,
handler,
});
handlerLogService.info('End');
}
natsService.subscribe(subject, {
callback: (error, message) => tslib_1.__awaiter(this, void 0, void 0, function* () {
let data = message.data
? requestCodec.decode(message.data)
: undefined;
const handlerLogService = registeredInjection.logService;
let injection;
try {
injection = Object.assign(Object.assign({}, registeredInjection), { message,
natsService });
handlerLogService.info('Begin');
if (!data) {
handlerLogService.error('Incoming message has no data');
yield respond({
message,
request: data,
response: {
headers: data === null || data === void 0 ? void 0 : data.headers,
body: undefined,
code: 400,
},
injection,
onResponse: handler.response,
});
handlerLogService.info('End');
return;
}
finally {
_d = true;
if (data.body) {
data = Object.assign(Object.assign({}, data), { body: data.body });
}
//#region Before
const beforeResult = yield before({
message,
data,
injection,
middlewares: middlewares.before,
});
if (beforeResult && beforeResult.code !== 'OK') {
handlerLogService.info('End');
return;
}
else if (beforeResult) {
data = beforeResult.data;
injection = beforeResult.injection;
}
//#endregion
//#region Handle
let handleResult = yield handle({
message,
data,
injection,
handler,
});
if (handleResult && handleResult.code !== 'OK') {
handlerLogService.info('End');
return;
}
//#endregion
//#region After
const afterResult = yield after({
message,
data,
result: handleResult,
injection,
middlewares: middlewares.after,
});
if (afterResult && afterResult.code !== 'OK') {
handlerLogService.info('End');
return;
}
else if (afterResult) {
data = afterResult.data;
handleResult = afterResult.result;
injection = afterResult.injection;
}
//#endregion
yield respond({
message,
request: data,
response: {
headers: (handleResult === null || handleResult === void 0 ? void 0 : handleResult.headers)
? Object.assign(Object.assign({}, data === null || data === void 0 ? void 0 : data.headers), handleResult === null || handleResult === void 0 ? void 0 : handleResult.headers) : data === null || data === void 0 ? void 0 : data.headers,
code: (handleResult === null || handleResult === void 0 ? void 0 : handleResult.code) === 'OK' ? 200 : handleResult === null || handleResult === void 0 ? void 0 : handleResult.code,
body: handleResult === null || handleResult === void 0 ? void 0 : handleResult.body,
},
injection,
onResponse: handler.response,
});
handlerLogService.info('End');
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (!_d && !_a && (_b = subcription_1.return)) yield _b.call(subcription_1);
catch (error) {
yield respondUnhandledError({
message,
data,
error,
injection,
handler,
});
handlerLogService.info('End');
}
finally { if (e_1) throw e_1.error; }
}
}))();
}),
});
});

@@ -161,0 +142,0 @@ return natsService;

{
"name": "@silenteer/natsu",
"version": "1.0.36",
"version": "1.0.37",
"license": "MIT",

@@ -5,0 +5,0 @@ "private": false,

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