Skip to content

Commit

Permalink
fix: sifrr server using same type
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityataparia committed Jun 6, 2019
1 parent ba309cb commit 9730c60
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 36 deletions.
20 changes: 9 additions & 11 deletions dist/sifrr.dev.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sifrr.dev.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/sifrr.dev.min.js

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions dist/sifrr.dev.module.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/sifrr.dev.module.js.map

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions src/test/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require('fs');
const loadDir = require('../loaddir');
const instrumenter = require('istanbul-lib-instrument').createInstrumenter();
const { App, SSLApp } = require('@sifrr/server');

function staticInstrument(app, folder, coverage = false) {
loadDir({
dir: folder,
Expand Down Expand Up @@ -42,15 +43,13 @@ module.exports = async function(root, {
staticInstrument(app, folder, coverage);
});

listeners.push(() => {
app.listen(hostingPort, (socket) => {
if (socket) {
global.console.log(`Test server listening on port ${hostingPort}, serving ${root}`);
} else {
global.console.log('Test server failed to listen to port ' + hostingPort);
}
});
});
listeners.push(app.listen.bind(app, hostingPort, (socket) => {
if (socket) {
global.console.log(`Test server listening on port ${hostingPort}, serving ${root}`);
} else {
global.console.log('Test server failed to listen to port ' + hostingPort);
}
}));
}

let normalApp, secureApp;
Expand All @@ -66,8 +65,9 @@ module.exports = async function(root, {
app = require(path.join(root, 'server.js'));
} else {
app = new App();
startServer(app, port);
}
if (typeof app.file === 'function') startServer(app, port);
else listeners.push(app.listen.bind(app, port));
normalApp = app;
}

Expand All @@ -85,8 +85,9 @@ module.exports = async function(root, {
key_file_name: path.join(__dirname, 'keys/server.key'),
cert_file_name: path.join(__dirname, 'keys/server.crt')
});
startServer(app, securePort);
}
if (typeof app.file === 'function') startServer(app, securePort);
else listeners.push(app.listen.bind(app, securePort));
secureApp = app;
}

Expand Down

0 comments on commit 9730c60

Please sign in to comment.