import { readFile } from "fs/promises";
import path from "node:path";
import { logger as puiLogger, Console } from "@elliemae/pui-diagnostics";
const getMajorMinorVersion = (version) => version.split(".").slice(0, 2).join(".");
const sendJS = async (res, ctx, filePath) => {
  const fileContent = await readFile(path.join(__dirname, filePath), "utf-8");
  return res.once(
    ctx.status(200),
    ctx.set("Content-Type", "application/javascript"),
    ctx.body(fileContent)
  );
};
const sendJSText = async (res, ctx, fileContent) => res.once(
  ctx.status(200),
  ctx.set("Content-Type", "application/javascript"),
  ctx.body(fileContent)
);
const releaseJSThread = () => new Promise((resolve) => {
  setTimeout(resolve, 0);
});
const logger = puiLogger({
  transport: Console(),
  index: "microfe",
  team: "ui platform",
  appName: "MicroFE Tests"
});
export {
  getMajorMinorVersion,
  logger,
  releaseJSThread,
  sendJS,
  sendJSText
};
