import fs from "node:fs";
import path from "node:path";
import { NextResponse } from "next/server";
import { z } from "zod";
const versionResponseSchema = z.object({
  version: z.string()
});
function readDeployedVersion() {
  const explicit = process.env.OM_VERSION || process.env.OPEN_MERCATO_VERSION;
  if (explicit && explicit.length > 0) return explicit;
  try {
    const packageJsonPath = path.join(process.cwd(), "package.json");
    const parsed = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
    if (typeof parsed.version === "string" && parsed.version.length > 0) return parsed.version;
  } catch {
  }
  return "0.0.0-dev";
}
const deployedVersion = readDeployedVersion();
const metadata = {
  path: "/version",
  GET: {
    requireAuth: false,
    rateLimit: { points: 30, duration: 60, keyPrefix: "api_version" }
  }
};
async function GET() {
  const body = { version: deployedVersion };
  return NextResponse.json(body);
}
var version_default = GET;
const openApi = {
  tag: "API Documentation",
  summary: "Deployed Open Mercato version",
  methods: {
    GET: {
      summary: "Return the deployed Open Mercato version",
      tags: ["API Documentation"],
      responses: [
        {
          status: 200,
          description: "Current deployment version metadata",
          schema: versionResponseSchema
        }
      ]
    }
  }
};
export {
  GET,
  version_default as default,
  metadata,
  openApi
};
//# sourceMappingURL=version.js.map
