"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var src_exports = {};
__export(src_exports, {
  app: () => app
});
module.exports = __toCommonJS(src_exports);
var import_express = __toESM(require("express"));
var import_auth = __toESM(require("./@lcp-framework/routes/common/auth.routes"));
var import_cron = __toESM(require("./@lcp-framework/routes/common/cron.routes"));
var import_datasync = __toESM(require("./@lcp-framework/routes/common/datasync.routes"));
var import_common = __toESM(require("./@lcp-framework/routes/admin/common.routes"));
var import_error = require("./@lcp-framework/middlewares/error.middleware");
var import_webhook = __toESM(require("./@lcp-framework/routes/common/webhook.routes"));
var import_swagger_ui_express = __toESM(require("swagger-ui-express"));
var import_swagger = __toESM(require("./swagger"));
var import_cors = __toESM(require("cors"));
var import_compression = __toESM(require("compression"));
var import_hpp = __toESM(require("hpp"));
var import_cookie_parser = __toESM(require("cookie-parser"));
var import_config = require("./config");
var import_path = __toESM(require("path"));
var import_app_api = __toESM(require("./app/routes/app-api.routes"));
var import_express_fileupload = __toESM(require("express-fileupload"));
var import_lcp_cron = __toESM(require("./@lcp-framework/utilities/lcp-cron"));
var import_openai = __toESM(require("./@lcp-framework/routes/admin/openai.routes"));
var import_migrate = __toESM(require("./@lcp-framework/routes/common/migrate.routes"));
var import_firebase = __toESM(require("./@lcp-framework/utilities/firebase"));
const app = (0, import_express.default)();
app.set("trust proxy", 1);
process.env.TZ = "UTC";
app.use((0, import_cors.default)());
app.use(
  (0, import_cors.default)({
    exposedHeaders: ["Content-Disposition"]
    // Allow frontend to read this header
  })
);
app.use((req, res, next) => {
  req.setTimeout(7e5);
  res.setTimeout(7e5);
  next();
});
app.use(import_express.default.json({ limit: "100mb" }));
app.use(import_express.default.urlencoded({ extended: true, limit: "100mb" }));
app.use(
  (0, import_express_fileupload.default)({
    createParentPath: true,
    limits: { fileSize: 100 * 1024 * 1024 },
    // 100MB limit for file size
    parseNested: true,
    debug: false
  })
);
app.use((0, import_hpp.default)());
app.use((0, import_compression.default)());
app.use((0, import_cookie_parser.default)());
app.use(import_express.default.static(import_path.default.join(__dirname, "./public")));
app.use("/api/cron", import_cron.default);
app.use("/api/datasync", import_datasync.default);
app.use("/api/auth", import_auth.default);
app.use("/api/common", import_common.default);
app.use("/api", import_app_api.default);
app.use("/api/openai", import_openai.default);
app.use("/api/hooks", import_webhook.default);
app.use("/api/migrate", import_migrate.default);
app.use("/api", import_error.errorHandler);
app.use(
  "/api-docs",
  import_swagger_ui_express.default.serve,
  import_swagger_ui_express.default.setup(import_swagger.default, { explorer: true })
);
app.use("/", (req, res) => {
  res.send("App runs successfully");
});
app.use(import_error.errorHandler);
app.listen(import_config.appDetails.port, async () => {
  console.log(
    `${import_config.appDetails.appName} server is running on port ${import_config.appDetails.port}`
  );
  if (process.env.NODE_ENV == "production" || process.env.NODE_ENV == "staging") {
    await import_lcp_cron.default.start();
  }
  import_firebase.default.firebaseInit();
});
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  app
});
