"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedirectGeneratedResponse = exports.HtmlGeneratedResponse = exports.TextGeneratedResponse = exports.BodyGeneratedResponse = exports.JsonGeneratedResponse = exports.Base64GeneratedResponse = exports.FileGeneratedResponse = exports.GeneratedResponse = void 0;
class GeneratedResponse {
}
exports.GeneratedResponse = GeneratedResponse;
class FileGeneratedResponse extends GeneratedResponse {
    constructor(filePath, fileName) {
        super();
        this.filePath = filePath;
        this.fileName = fileName;
    }
    getResponse(response) {
        response.download(this.filePath, this.fileName);
        return response;
    }
}
exports.FileGeneratedResponse = FileGeneratedResponse;
class Base64GeneratedResponse extends GeneratedResponse {
    constructor(name, base64, type) {
        super();
        this.name = name;
        this.base64 = base64;
        this.type = type;
    }
    getResponse(response) {
        response.header('Content-Disposition', 'attachment; filename="' + this.name + '"');
        if (this.type) {
            response.type(this.type);
        }
        response.send(Buffer.from(this.base64, 'base64'));
        return response;
    }
}
exports.Base64GeneratedResponse = Base64GeneratedResponse;
class JsonGeneratedResponse extends GeneratedResponse {
    constructor(json) {
        super();
        this.json = json;
    }
    getResponse(response) {
        response.json(this.json);
        return response;
    }
}
exports.JsonGeneratedResponse = JsonGeneratedResponse;
class BodyGeneratedResponse extends GeneratedResponse {
    constructor(response, contentType, noCache = true) {
        super();
        this.response = response;
        this.contentType = contentType;
        this.noCache = noCache;
    }
    getResponse(response) {
        if (this.contentType && '' !== this.contentType) {
            response.set('Content-Type', this.contentType);
        }
        else {
            response.set('Content-Type', 'text/html');
        }
        if (this.noCache) {
            response.set('Cache-Control', 'private,no-cache,no-store,max-age=0,must-revalidate,pre-check=0,post-check=0');
        }
        response.send(this.response);
        return response;
    }
}
exports.BodyGeneratedResponse = BodyGeneratedResponse;
class TextGeneratedResponse extends BodyGeneratedResponse {
    constructor(response, noCache = true) {
        super(response, 'text/plain', noCache);
        this.response = response;
        this.noCache = noCache;
    }
}
exports.TextGeneratedResponse = TextGeneratedResponse;
class HtmlGeneratedResponse extends BodyGeneratedResponse {
    constructor(response, noCache = true) {
        super(response, 'text/html', noCache);
        this.response = response;
        this.noCache = noCache;
    }
}
exports.HtmlGeneratedResponse = HtmlGeneratedResponse;
class RedirectGeneratedResponse extends GeneratedResponse {
    constructor(uri) {
        super();
        this.uri = uri;
    }
    getResponse(response) {
        response.redirect(this.uri);
        return response;
    }
}
exports.RedirectGeneratedResponse = RedirectGeneratedResponse;
//# sourceMappingURL=generated-response.js.map