Skip to content

Commit

Permalink
Remove apiGatewayUrl from websocket event
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jul 3, 2019
1 parent 4f5ce66 commit c0bea4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/ApiGatewayWebSocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ module.exports = class ApiGatewayWebSocket {

this.clients.delete(ws);

const event = wsHelpers.createDisconnectEvent('$disconnect', 'DISCONNECT', connection, this.options);
const event = wsHelpers.createDisconnectEvent('$disconnect', 'DISCONNECT', connection);

doAction(ws, connection.connectionId, '$disconnect', event, false);
},
Expand Down Expand Up @@ -216,7 +216,7 @@ module.exports = class ApiGatewayWebSocket {

debugLog(`action:${action} on connection=${connection.connectionId}`);

const event = wsHelpers.createEvent(action, 'MESSAGE', connection, request.payload, this.options);
const event = wsHelpers.createEvent(action, 'MESSAGE', connection, request.payload);

doAction(ws, connection.connectionId, action, event, true);

Expand Down
7 changes: 2 additions & 5 deletions src/websocketHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ const createRequestContext = (action, eventType, connection) => {
return requestContext;
};

exports.createEvent = (action, eventType, connection, payload, options) => {
exports.createEvent = (action, eventType, connection, payload) => {
const event = {
apiGatewayUrl: `http${options.httpsProtocol ? 's' : ''}://${options.host}:${options.port + 1}`,
body: JSON.stringify(payload),
isBase64Encoded: false,
requestContext: createRequestContext(action, eventType, connection),
Expand All @@ -85,7 +84,6 @@ exports.createConnectEvent = (action, eventType, connection, options) => {
};
const multiValueHeaders = createMultiValueHeaders(headers);
const event = {
apiGatewayUrl: `http${options.httpsProtocol ? 's' : ''}://${options.host}:${options.port + 1}`,
headers,
isBase64Encoded: false,
multiValueHeaders,
Expand All @@ -95,15 +93,14 @@ exports.createConnectEvent = (action, eventType, connection, options) => {
return event;
};

exports.createDisconnectEvent = (action, eventType, connection, options) => {
exports.createDisconnectEvent = (action, eventType, connection) => {
const headers = {
Host: 'localhost',
'x-api-key': '',
'x-restapi': '',
};
const multiValueHeaders = createMultiValueHeaders(headers);
const event = {
apiGatewayUrl: `http${options.httpsProtocol ? 's' : ''}://${options.host}:${options.port + 1}`,
headers,
isBase64Encoded: false,
multiValueHeaders,
Expand Down

0 comments on commit c0bea4c

Please sign in to comment.