Skip to content

Commit

Permalink
Added check for socketApiKey
Browse files Browse the repository at this point in the history
  • Loading branch information
MKHenson committed Oct 16, 2016
1 parent 2cca1c1 commit 466a514
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/socket-api/comms-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ export class CommsController extends events.EventEmitter {
CommsController.singleton = this;
this._connections = [];
this._cfg = cfg;
this._hashedApiKey = bcrypt.hashSync( cfg.websocket.socketApiKey );


}

/**
Expand Down Expand Up @@ -163,6 +160,12 @@ export class CommsController extends events.EventEmitter {
async initialize(): Promise<void> {
let cfg = this._cfg;

// Throw error if no socket api key
if ( !cfg.websocket.socketApiKey )
throw new Error( 'The socketApiKey was not set in the config file. Make sure it exists (Check the example-config.json) ' );

this._hashedApiKey = bcrypt.hashSync( cfg.websocket.socketApiKey );

// dummy request processing - this is not actually called as its handed off to the socket api
const processRequest = function( req, res ) {
req; // Suppress compiler warning
Expand Down

0 comments on commit 466a514

Please sign in to comment.