Skip to content

Commit

Permalink
feat: forward events to Inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
gabidobo committed Sep 29, 2022
1 parent c9aed95 commit 1862309
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/recorder.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const http = require('http');
const {RECORDER_PORT} = require('./constants');
const {RECORDER_PORT, INSPECTOR_PORT} = require('./constants');

const logger = console;
let activity = [];
Expand All @@ -25,6 +25,16 @@ const handleRequest = (request, response) => {
'Access-Control-Allow-Origin': '*',
});
response.end();

const req = http.request({
port: INSPECTOR_PORT,
host: '127.0.0.1',
path: '/ingest',
method: 'POST',
headers: {'content-type': 'application/json'},
});
req.on('error', () => {});
req.end(stringBody);
} catch (error) {
logger.error(error);
response.writeHead(500, {
Expand Down Expand Up @@ -66,11 +76,12 @@ const recordSandwormActivityAsync = (onError, done) => {
sockets.delete(socket);
});
});
}
};

const recordSandwormActivityPromise = (onError) => new Promise((resolve) => {
recordSandwormActivityAsync(onError, resolve);
})
const recordSandwormActivityPromise = (onError) =>
new Promise((resolve) => {
recordSandwormActivityAsync(onError, resolve);
});

const recordSandwormActivity = (onError, done) => {
if (done) {
Expand All @@ -96,7 +107,8 @@ const stopRecordingSandwormActivityAsync = (done) => {
});
};

const stopRecordingSandwormActivityPromise = () => new Promise((resolve) => {
const stopRecordingSandwormActivityPromise = () =>
new Promise((resolve) => {
stopRecordingSandwormActivityAsync(resolve);
});

Expand Down

0 comments on commit 1862309

Please sign in to comment.