"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mock429 = void 0;
const tslib_1 = require("tslib");
const express_1 = (0, tslib_1.__importDefault)(require("express"));
const shared_1 = require("./shared");
class Mock429 {
    constructor() {
        this.responseSent = false;
    }
    initialize() {
        return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
            const app = (0, express_1.default)();
            app.get('/', (req, res, next) => {
                if (!this.responseSent) {
                    this.responseSent = true;
                    res.header('retry-after', '2');
                    return res.sendStatus(429);
                }
                return res.sendStatus(200);
            });
            this.server = yield (0, shared_1.randomListen)(app);
            return (0, shared_1.getPort)(this.server);
        });
    }
    terminate() {
        return (0, shared_1.terminateServer)(this.server);
    }
}
exports.Mock429 = Mock429;
//# sourceMappingURL=mock-429.js.map