import "../../../../../base64-CmWvODNW.mjs";
import "../../../../../types-CuW0zWDA.mjs";
import { a as unwrapResult, r as handleError, t as apiError } from "../../../../../error-CkAseSqZ.mjs";
import { n as parseBody, t as isParseError } from "../../../../../parse-GmjecGct.mjs";
import "../../../../../api-tokens-DsvvCtdh.mjs";
import "../../../../../oauth-user-lookup-Bsc_GsX-.mjs";
import { a as handleTokenRevoke } from "../../../../../device-flow-CfGP18Uw.mjs";
import { z } from "zod";

//#region src/astro/routes/api/oauth/token/revoke.ts
const prerender = false;
const revokeSchema = z.object({ token: z.string().min(1) });
const POST = async ({ request, locals }) => {
	const { emdash } = locals;
	if (!emdash?.db) return apiError("NOT_CONFIGURED", "EmDash is not initialized", 500);
	try {
		const body = await parseBody(request, revokeSchema);
		if (isParseError(body)) return body;
		return unwrapResult(await handleTokenRevoke(emdash.db, body));
	} catch (error) {
		return handleError(error, "Failed to revoke token", "TOKEN_REVOKE_ERROR");
	}
};

//#endregion
export { POST, prerender };
//# sourceMappingURL=revoke.mjs.map