@silenteer/natsu-port-server
Advanced tools
Comparing version 0.0.26 to 0.0.27
@@ -6,2 +6,4 @@ "use strict"; | ||
const yup = (0, tslib_1.__importStar)(require("yup")); | ||
const dotenv_1 = (0, tslib_1.__importDefault)(require("dotenv")); | ||
dotenv_1.default.config(); | ||
const schema = yup.object({ | ||
@@ -8,0 +10,0 @@ natsURI: yup.string().trim().required(), |
@@ -0,1 +1,2 @@ | ||
import 'colors'; | ||
declare function start(): void; | ||
@@ -2,0 +3,0 @@ declare const _default: { |
@@ -10,2 +10,3 @@ "use strict"; | ||
const fastify_websocket_1 = (0, tslib_1.__importDefault)(require("fastify-websocket")); | ||
require("colors"); | ||
const configuration_1 = (0, tslib_1.__importDefault)(require("./configuration")); | ||
@@ -38,3 +39,8 @@ const service_nats_1 = (0, tslib_1.__importDefault)(require("./service-nats")); | ||
var _a; | ||
const subject = request.headers['nats-subject']; | ||
try { | ||
console.log(`----- [${subject}]Begin validate -----`, { | ||
headers: request.headers, | ||
body: request.body, | ||
}); | ||
const validationResult = validateHttpRequest(request); | ||
@@ -45,2 +51,4 @@ if (validationResult.code === 400) { | ||
} | ||
console.log(`----- [${subject}]End validate -----`, validationResult); | ||
console.log(`----- [${subject}]Begin authenticate -----`); | ||
const authenticationResult = yield authenticate(request); | ||
@@ -54,2 +62,4 @@ if (authenticationResult.code !== 'OK') { | ||
} | ||
console.log(`----- [${subject}]End authenticate -----`); | ||
console.log(`----- [${subject}]Begin send nats request -----`); | ||
const response = yield sendNatsRequest({ | ||
@@ -59,6 +69,7 @@ httpRequest: request, | ||
}); | ||
console.log(`----- [${subject}]End send nats request -----`); | ||
reply.send(response); | ||
} | ||
catch (error) { | ||
console.error(request.headers['nats-subject'], error); | ||
console.error(subject, error); | ||
if (error.code) { | ||
@@ -172,2 +183,3 @@ reply.send(error); | ||
if (shouldAuthenticate) { | ||
console.log(`----- [${subject}]Begin send nats auth request -----`); | ||
const natsAuthResponse = yield sendNatsAuthRequest(request); | ||
@@ -179,3 +191,2 @@ if (natsAuthResponse.code !== 200) { | ||
}; | ||
return result; | ||
} | ||
@@ -187,4 +198,5 @@ else { | ||
}; | ||
return result; | ||
} | ||
console.log(`----- [${subject}]End send nats auth request -----`); | ||
return result; | ||
} | ||
@@ -235,2 +247,3 @@ result = { code: 'OK' }; | ||
}; | ||
console.log(`----- [${request.headers['nats-subject']}][${subject}] Sending -----`, natsRequest); | ||
const message = yield service_nats_1.default.request({ | ||
@@ -241,2 +254,3 @@ subject, | ||
natsResponse = responseCodec.decode(message.data); | ||
console.log(`----- [${request.headers['nats-subject']}][${subject}] Ending -----`, natsResponse); | ||
if (natsResponse.code !== 200) { | ||
@@ -257,2 +271,3 @@ break; | ||
}; | ||
console.log(`----- [${natsRequest.headers['nats-subject']}] Sending -----`, natsRequest); | ||
const message = yield service_nats_1.default.request({ | ||
@@ -267,2 +282,3 @@ subject: httpRequest.headers['nats-subject'], | ||
}; | ||
console.log(`----- [${natsRequest.headers['nats-subject']}] Ending -----`, portResponse); | ||
return portResponse; | ||
@@ -269,0 +285,0 @@ }); |
@@ -49,3 +49,4 @@ "use strict"; | ||
const { subject, data, options } = params; | ||
return (yield getConnection()).request(subject, data, Object.assign(Object.assign({}, defaultRequestOptions), options)); | ||
const connection = yield getConnection(); | ||
return connection.request(subject, data, Object.assign(Object.assign({}, defaultRequestOptions), options)); | ||
}); | ||
@@ -52,0 +53,0 @@ } |
{ | ||
"name": "@silenteer/natsu-port-server", | ||
"version": "0.0.26", | ||
"version": "0.0.27", | ||
"license": "MIT", | ||
@@ -27,6 +27,9 @@ "private": false, | ||
"cli-table3": "0.6.0", | ||
"colors": "^1.4.0", | ||
"dotenv": "^16.0.0", | ||
"fastify": "3.21.0", | ||
"fastify-cors": "6.0.2", | ||
"fastify-websocket": "4.0.0", | ||
"nats": "2.2.0", | ||
"nats": "2.6.1", | ||
"uri-js": "^4.4.1", | ||
"yup": "0.32.9" | ||
@@ -33,0 +36,0 @@ }, |
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
43162
666
11
+ Addedcolors@^1.4.0
+ Addeddotenv@^16.0.0
+ Addeduri-js@^4.4.1
+ Addeddotenv@16.4.7(transitive)
+ Addednats@2.6.1(transitive)
- Removednats@2.2.0(transitive)
Updatednats@2.6.1