UNPKG

outers

Version:

outers - a all in one package for your day to day use

36 lines 1.67 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /* eslint-disable @typescript-eslint/no-explicit-any */ // Constants const Response_Constant_1 = require("../Config/Constant/Response.Constant"); // Import JPG_REGEX /** * Renders a response with provided parameters. * @param {RenderResponseInterface} options - An object containing parameters for rendering the response. * @param {number} options.statusCode - The HTTP status code to be set. * @param {string} options.FileName - The name of the template file to render. * @param {Object} options.Variables - The variables to be passed to the template file. * @param {Array} options.cookieData - An array of objects representing cookie data to be set. * @param {Response} options.response - The Express response object. * @param {string} options.contentType - The content type of the response. */ function RenderResponse({ statusCode, FileName, Variables, cookieData, response, contentType, }) { // Set Content Type if available if (contentType) { for (const Type of Response_Constant_1.MIME_Types) { if (Type.toLowerCase().includes(contentType.toLowerCase())) { response.setHeader("Content-Type", Type); break; } } } // Add Cookie Data if available if (cookieData) { cookieData.forEach(({ name, value, options }) => { response.cookie(name, value, options); // sets cookie }); } // Set status code and render file response.status(statusCode).render(FileName, Variables); } exports.default = RenderResponse; //# sourceMappingURL=Render-Response.js.map