@silenteer/natsu
Advanced tools
Comparing version 1.0.32 to 1.0.33
import type { NatsChannel, NatsService } from '@silenteer/natsu-type'; | ||
import type { ConnectionOptions, Msg, RequestOptions } from 'nats'; | ||
declare type Service = NatsService<string, unknown, unknown>; | ||
declare type Channel = NatsChannel<string, unknown, unknown>; | ||
type Service = NatsService<string, unknown, unknown>; | ||
type Channel = NatsChannel<string, unknown, unknown>; | ||
declare function createHeaders(entries: Record<string, string[]>): import("nats").MsgHdrs; | ||
declare type ClientOptions = ConnectionOptions & { | ||
type ClientOptions = ConnectionOptions & { | ||
defaultRequestOptions?: RequestOptions; | ||
@@ -8,0 +8,0 @@ defaultSubsOptions?: RequestOptions; |
@@ -16,3 +16,3 @@ "use strict"; | ||
const { encode, decode } = (0, nats_1.JSONCodec)(); | ||
const request = (subject, data, options) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
const request = (subject, data, options) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const connection = yield nc; | ||
@@ -23,12 +23,19 @@ const body = encode(data); | ||
}); | ||
const subscribe = (subject, handler) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
const subscribe = (subject, handler) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const connection = yield nc; | ||
const sub = connection.subscribe(subject, clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.defaultSubsOptions); | ||
(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
var e_1, _a; | ||
(() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
var _a, e_1, _b, _c; | ||
try { | ||
for (var sub_1 = (0, tslib_1.__asyncValues)(sub), sub_1_1; sub_1_1 = yield sub_1.next(), !sub_1_1.done;) { | ||
const m = sub_1_1.value; | ||
const body = decode(m.data); | ||
handler(body, { msg: m }); | ||
for (var _d = true, sub_1 = tslib_1.__asyncValues(sub), sub_1_1; sub_1_1 = yield sub_1.next(), _a = sub_1_1.done, !_a;) { | ||
_c = sub_1_1.value; | ||
_d = false; | ||
try { | ||
const m = _c; | ||
const body = decode(m.data); | ||
handler(body, { msg: m }); | ||
} | ||
finally { | ||
_d = true; | ||
} | ||
} | ||
@@ -39,3 +46,3 @@ } | ||
try { | ||
if (sub_1_1 && !sub_1_1.done && (_a = sub_1.return)) yield _a.call(sub_1); | ||
if (!_d && !_a && (_b = sub_1.return)) yield _b.call(sub_1); | ||
} | ||
@@ -42,0 +49,0 @@ finally { if (e_1) throw e_1.error; } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
const nats_client_1 = (0, tslib_1.__importDefault)(require("./nats-client")); | ||
const nats_client_1 = tslib_1.__importDefault(require("./nats-client")); | ||
exports.default = nats_client_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -12,3 +12,3 @@ "use strict"; | ||
function start(params) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { urls, user, pass, verbose, logLevels, handlers, injection, onCreateNatsService, } = params; | ||
@@ -35,3 +35,3 @@ if (!handlers || handlers.length === 0) { | ||
handlers, | ||
injection: yield injection(natsService), | ||
injection: injection ? yield injection(natsService) : undefined, | ||
logLevels, | ||
@@ -41,90 +41,97 @@ }); | ||
const subcription = natsService.subscribe(subject); | ||
(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
var e_1, _a; | ||
(() => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
var _a, e_1, _b, _c; | ||
try { | ||
for (var subcription_1 = (0, tslib_1.__asyncValues)(subcription), subcription_1_1; subcription_1_1 = yield subcription_1.next(), !subcription_1_1.done;) { | ||
const message = subcription_1_1.value; | ||
let data = message.data | ||
? requestCodec.decode(message.data) | ||
: undefined; | ||
const handlerLogService = registeredInjection.logService; | ||
let injection; | ||
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 { | ||
injection = Object.assign(Object.assign({}, registeredInjection), { message, | ||
natsService }); | ||
handlerLogService.info('Begin'); | ||
if (!data) { | ||
handlerLogService.error('Incoming message has no data'); | ||
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'); | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { body: undefined, code: 400 })), | ||
}); | ||
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 | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { body: undefined, code: 400 })), | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { 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 })), | ||
}); | ||
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') { | ||
catch (error) { | ||
yield respondUnhandledError({ | ||
message, | ||
data, | ||
error, | ||
injection, | ||
handler, | ||
}); | ||
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 | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { 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 })), | ||
}); | ||
handlerLogService.info('End'); | ||
} | ||
catch (error) { | ||
yield respondUnhandledError({ | ||
message, | ||
data, | ||
error, | ||
injection, | ||
handler, | ||
}); | ||
handlerLogService.info('End'); | ||
finally { | ||
_d = true; | ||
} | ||
@@ -136,3 +143,3 @@ } | ||
try { | ||
if (subcription_1_1 && !subcription_1_1.done && (_a = subcription_1.return)) yield _a.call(subcription_1); | ||
if (!_d && !_a && (_b = subcription_1.return)) yield _b.call(subcription_1); | ||
} | ||
@@ -147,3 +154,3 @@ finally { if (e_1) throw e_1.error; } | ||
function stop(natsService) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
yield (natsService === null || natsService === void 0 ? void 0 : natsService.drain()); | ||
@@ -153,3 +160,3 @@ }); | ||
function register(params) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { injection, handlers, logLevels } = params; | ||
@@ -186,6 +193,6 @@ const result = {}; | ||
return { | ||
request: (subject, data, opts) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
request: (subject, data, opts) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return client.request(subject, (0, nats_1.JSONCodec)().encode(data), opts); | ||
}), | ||
publish: (subject, data, opts) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
publish: (subject, data, opts) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return client.publish(subject, (0, nats_1.JSONCodec)().encode(data), opts); | ||
@@ -196,3 +203,3 @@ }), | ||
}, | ||
drain: () => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
drain: () => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
return client.drain(); | ||
@@ -255,3 +262,3 @@ }), | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { ok, error } = injection, rest = (0, tslib_1.__rest)(injection, ["ok", "error"]); | ||
const { ok, error } = injection, rest = tslib_1.__rest(injection, ["ok", "error"]); | ||
return { | ||
@@ -265,3 +272,3 @@ code: 'OK', | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { ok, error } = injection, rest = (0, tslib_1.__rest)(injection, ["ok", "error"]); | ||
const { ok, error } = injection, rest = tslib_1.__rest(injection, ["ok", "error"]); | ||
return { | ||
@@ -280,3 +287,3 @@ code, | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { ok, error } = injection, rest = (0, tslib_1.__rest)(injection, ["ok", "error"]); | ||
const { ok, error } = injection, rest = tslib_1.__rest(injection, ["ok", "error"]); | ||
return { | ||
@@ -291,3 +298,3 @@ code: 'OK', | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { ok, error } = injection, rest = (0, tslib_1.__rest)(injection, ["ok", "error"]); | ||
const { ok, error } = injection, rest = tslib_1.__rest(injection, ["ok", "error"]); | ||
return { | ||
@@ -305,3 +312,3 @@ code, | ||
var _a; | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { injection, handler } = params; | ||
@@ -317,4 +324,4 @@ const before = []; | ||
middlewareId, | ||
handle: (params) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
const { injection } = params, rest = (0, tslib_1.__rest)(params, ["injection"]); | ||
handle: (params) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { injection } = params, rest = tslib_1.__rest(params, ["injection"]); | ||
const middlewareLogService = createLogService({ | ||
@@ -335,3 +342,3 @@ prefix: `[${middleware.id}][before]`, | ||
middlewareLogService.error(error); | ||
throw new UnhandledMiddlewareError(); | ||
throw new UnhandledMiddlewareError(error); | ||
} | ||
@@ -344,4 +351,4 @@ }), | ||
middlewareId, | ||
handle: (params) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
const { injection } = params, rest = (0, tslib_1.__rest)(params, ["injection"]); | ||
handle: (params) => tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { injection } = params, rest = tslib_1.__rest(params, ["injection"]); | ||
const middlewareLogService = createLogService({ | ||
@@ -362,3 +369,3 @@ prefix: `[${middleware.id}][after]`, | ||
middlewareLogService.error(error); | ||
throw new UnhandledMiddlewareError(); | ||
throw new UnhandledMiddlewareError(error); | ||
} | ||
@@ -377,3 +384,3 @@ }), | ||
function before(params) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { message, data, injection, middlewares } = params; | ||
@@ -400,3 +407,3 @@ let beforeResult; | ||
function handle(params) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { message, data, injection, handler } = params; | ||
@@ -434,3 +441,3 @@ let handleResult; | ||
function after(params) { | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { message, data, result, injection, middlewares } = params; | ||
@@ -459,3 +466,3 @@ let afterResult; | ||
var _a, _b; | ||
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
const { message, data, error, injection, handler } = params; | ||
@@ -494,3 +501,3 @@ const isUnhandledMiddlewareError = error instanceof UnhandledMiddlewareError; | ||
const client = { | ||
start: () => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
start: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
natsService = yield start({ | ||
@@ -508,3 +515,3 @@ urls, | ||
}), | ||
stop: () => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
stop: () => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
yield stop(natsService); | ||
@@ -515,3 +522,3 @@ natsService = undefined; | ||
}), | ||
register: (handlers) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () { | ||
register: (handlers) => tslib_1.__awaiter(void 0, void 0, void 0, function* () { | ||
if (isStarted) { | ||
@@ -518,0 +525,0 @@ throw new Error(`Can't register more handler after nats client started`); |
import type { Msg, NatsConnection, PublishOptions, RequestOptions } from 'nats'; | ||
import type { NatsService, NatsRequest, NatsResponse } from '@silenteer/natsu-type'; | ||
declare type NatsInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = TInjection & { | ||
type NatsInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = TInjection & { | ||
subject: string; | ||
@@ -26,11 +26,11 @@ message: Msg; | ||
}; | ||
declare type NatsValidationResult = { | ||
type NatsValidationResult = { | ||
code: 'OK' | number; | ||
errors?: unknown; | ||
}; | ||
declare type NatsAuthorizationResult = { | ||
type NatsAuthorizationResult = { | ||
code: 'OK' | number; | ||
errors?: unknown; | ||
}; | ||
declare type NatsHandleResult<TService extends NatsService<string, unknown, unknown>> = { | ||
type NatsHandleResult<TService extends NatsService<string, unknown, unknown>> = { | ||
code: 'OK' | number; | ||
@@ -43,3 +43,3 @@ headers?: { | ||
}; | ||
declare type NatsMiddlewareBeforeResult<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
type NatsMiddlewareBeforeResult<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
code: 'OK' | number; | ||
@@ -50,3 +50,3 @@ data: NatsRequest<TService['request']>; | ||
}; | ||
declare type NatsMiddlewareAfterResult<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
type NatsMiddlewareAfterResult<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
code: 'OK' | number; | ||
@@ -58,3 +58,3 @@ data: NatsRequest<TService['request']>; | ||
}; | ||
declare type NatsMiddlewareBeforeInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
type NatsMiddlewareBeforeInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
ok: (params: { | ||
@@ -71,3 +71,3 @@ data: NatsRequest<TService['request']>; | ||
}; | ||
declare type NatsMiddlewareAfterInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
type NatsMiddlewareAfterInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
ok: (params: { | ||
@@ -86,3 +86,3 @@ data: NatsRequest<TService['request']>; | ||
}; | ||
declare type NatsValidationInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
type NatsValidationInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
ok: () => NatsValidationResult; | ||
@@ -94,3 +94,3 @@ error: (params?: { | ||
}; | ||
declare type NatsAuthorizationInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
type NatsAuthorizationInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
ok: () => NatsAuthorizationResult; | ||
@@ -102,3 +102,3 @@ error: (params?: { | ||
}; | ||
declare type NatsHandleInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
type NatsHandleInjection<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = NatsInjection<TService, TInjection> & { | ||
ok: (params?: Pick<NatsHandleResult<TService>, 'headers' | 'body'>) => NatsHandleResult<TService>; | ||
@@ -110,7 +110,7 @@ error: (params?: { | ||
}; | ||
declare type NatsBefore<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (params: { | ||
type NatsBefore<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (params: { | ||
data: NatsRequest<TService['request']>; | ||
injection: NatsMiddlewareBeforeInjection<TService, TInjection>; | ||
}) => Promise<NatsMiddlewareBeforeResult<TService, TInjection>>; | ||
declare type NatsAfter<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (params: { | ||
type NatsAfter<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (params: { | ||
data: NatsRequest<TService['request']>; | ||
@@ -120,6 +120,6 @@ result: NatsHandleResult<TService>; | ||
}) => Promise<NatsMiddlewareAfterResult<TService, TInjection>>; | ||
declare type NatsValidate<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (data: NatsRequest<TService['request']>, injection: NatsValidationInjection<TService, TInjection>) => Promise<NatsValidationResult>; | ||
declare type NatsAuthorize<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (data: NatsRequest<TService['request']>, injection: NatsAuthorizationInjection<TService, TInjection>) => Promise<NatsAuthorizationResult>; | ||
declare type NatsHandle<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (data: NatsRequest<TService['request']>, injection: NatsHandleInjection<TService, TInjection>) => Promise<NatsHandleResult<TService>>; | ||
declare type NatsMiddleware<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
type NatsValidate<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (data: NatsRequest<TService['request']>, injection: NatsValidationInjection<TService, TInjection>) => Promise<NatsValidationResult>; | ||
type NatsAuthorize<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (data: NatsRequest<TService['request']>, injection: NatsAuthorizationInjection<TService, TInjection>) => Promise<NatsAuthorizationResult>; | ||
type NatsHandle<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = (data: NatsRequest<TService['request']>, injection: NatsHandleInjection<TService, TInjection>) => Promise<NatsHandleResult<TService>>; | ||
type NatsMiddleware<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
id: string; | ||
@@ -133,3 +133,3 @@ init: (params: { | ||
}; | ||
declare type NatsHandler<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
type NatsHandler<TService extends NatsService<string, unknown, unknown>, TInjection extends Record<string, unknown> = Record<string, unknown>> = { | ||
subject: TService['subject']; | ||
@@ -136,0 +136,0 @@ validate: NatsValidate<TService, TInjection>; |
{ | ||
"name": "@silenteer/natsu", | ||
"version": "1.0.32", | ||
"version": "1.0.33", | ||
"license": "MIT", | ||
@@ -31,4 +31,4 @@ "private": false, | ||
"tslib": "2.3.1", | ||
"typescript": "4.4.3" | ||
"typescript": "4.9.5" | ||
} | ||
} |
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
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
53405
754