"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.terminateServer = exports.getPort = exports.randomListen = void 0;
function randomListen(app) {
    return new Promise(res => {
        const server = app.listen(0, () => res(server));
    });
}
exports.randomListen = randomListen;
function getPort(server) {
    const address = server.address();
    return address.port;
}
exports.getPort = getPort;
function terminateServer(server) {
    if (!server)
        return Promise.resolve();
    return new Promise((res, rej) => {
        server.close(err => {
            if (err)
                return rej(err);
            return res();
        });
    });
}
exports.terminateServer = terminateServer;
//# sourceMappingURL=shared.js.map