@silenteer/natsu
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -45,31 +45,39 @@ "use strict"; | ||
const injection = Object.assign(Object.assign({}, params.injections), { message, natsService: client }); | ||
const validationResult = yield handler.validate(data, injection); | ||
if (validationResult.code !== 'OK') { | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { code: validationResult.code, body: encodeBody(validationResult.errors) })), | ||
}); | ||
continue; | ||
if (handler.validate) { | ||
const validationResult = yield handler.validate(data, injection); | ||
if (validationResult.code !== 'OK') { | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { code: validationResult.code, body: encodeBody(validationResult.errors) })), | ||
}); | ||
continue; | ||
} | ||
} | ||
const authorizationResult = yield handler.authorize(data, injection); | ||
if (authorizationResult.code !== 'OK') { | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { code: authorizationResult.code, body: encodeBody(authorizationResult.message) })), | ||
}); | ||
continue; | ||
if (handler.authorize) { | ||
const authorizationResult = yield handler.authorize(data, injection); | ||
if (authorizationResult.code !== 'OK') { | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { code: authorizationResult.code, body: encodeBody(authorizationResult.message) })), | ||
}); | ||
continue; | ||
} | ||
} | ||
const handleResult = yield handler.handle(data, injection); | ||
if (handleResult.code !== 200) { | ||
if (handler.handle) { | ||
const handleResult = yield handler.handle(data, injection); | ||
if (handleResult.code !== 200) { | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { code: handleResult.code, body: encodeBody(handleResult.errors) })), | ||
}); | ||
continue; | ||
} | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { code: handleResult.code, body: encodeBody(handleResult.errors) })), | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { headers: handleResult.headers | ||
? Object.assign(Object.assign({}, data.headers), handleResult.headers) : data.headers, code: handleResult.code, body: encodeBody(handleResult.body) })), | ||
}); | ||
continue; | ||
} | ||
respond({ | ||
message, | ||
data: responseCodec.encode(Object.assign(Object.assign({}, data), { headers: handleResult.headers | ||
? Object.assign(Object.assign({}, data.headers), handleResult.headers) : data.headers, code: handleResult.code, body: encodeBody(handleResult.body) })), | ||
}); | ||
respond({ message }); | ||
} | ||
@@ -76,0 +84,0 @@ catch (error) { |
{ | ||
"name": "@silenteer/natsu", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "private": false, |
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
19613
264