"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var response_exports = {}; __export(response_exports, { endResponse: () => endResponse, makeResponse: () => makeResponse }); module.exports = __toCommonJS(response_exports); var import_errors = require("./errors"); function resolve(content) { const code = "code" in content ? content.code : content.status; const message = code >= 500 ? import_errors.ERROR_MESSAGES.INTERNAL_SERVER_ERROR.message : content.message; return { code, message }; } function buildBody(code, message, data) { if (code >= 400) { return { status: "FAILED", message }; } return { status: "OK", ...message !== void 0 ? { message } : {}, ...data !== void 0 ? { data } : {} }; } async function makeResponse({ ctr, content }) { const { code, message } = resolve(content); const data = "data" in content ? content.data : void 0; return ctr.status(code).print(buildBody(code, message, data)); } async function endResponse({ ctr, end, content }) { const { code, message } = resolve(content); const data = "data" in content ? content.data : void 0; ctr.status(code).print(buildBody(code, message, data)); end(); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { endResponse, makeResponse }); //# sourceMappingURL=response.js.map