refactor: http listen

This commit is contained in:
cha0s 2021-01-07 01:23:01 -06:00
parent c6d77047f5
commit 6b3fdb746c

View File

@ -92,7 +92,13 @@ export const createHttpServer = async (latus) => {
});
}
return new Promise((resolve, reject) => {
httpServer.listen(HTTP_PORT || port, HTTP_HOST || host, async (error) => {
const serverPort = HTTP_PORT || port;
const serverHost = HTTP_HOST || host;
const args = [serverPort];
if (serverHost) {
args.push(serverHost);
}
args.push(async (error) => {
if (error) {
return reject(error);
}
@ -101,6 +107,7 @@ export const createHttpServer = async (latus) => {
resolve();
return undefined;
});
httpServer.listen(...args);
});
};