"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MockJoinPeerTubeVersions = void 0;
const tslib_1 = require("tslib");
const express_1 = tslib_1.__importDefault(require("express"));
const shared_1 = require("./shared");
class MockJoinPeerTubeVersions {
    initialize() {
        return tslib_1.__awaiter(this, void 0, void 0, function* () {
            const app = (0, express_1.default)();
            app.use('/', (req, res, next) => {
                if (process.env.DEBUG)
                    console.log('Receiving request on mocked server %s.', req.url);
                return next();
            });
            app.get('/versions.json', (req, res) => {
                return res.json({
                    peertube: {
                        latestVersion: this.latestVersion
                    }
                });
            });
            this.server = yield (0, shared_1.randomListen)(app);
            return (0, shared_1.getPort)(this.server);
        });
    }
    setLatestVersion(latestVersion) {
        this.latestVersion = latestVersion;
    }
}
exports.MockJoinPeerTubeVersions = MockJoinPeerTubeVersions;
//# sourceMappingURL=mock-joinpeertube-versions.js.map