Public rule and detail page added

This commit is contained in:
adilallo
2026-04-21 22:35:49 -06:00
parent 2d58887a15
commit 0e7a57052b
4 changed files with 226 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
import { NextResponse } from "next/server";
import { isDatabaseConfigured } from "../../../../lib/server/env";
import { dbUnavailable } from "../../../../lib/server/responses";
import { getPublicPublishedRuleById } from "../../../../lib/server/publishedRules";
type RouteContext = { params: Promise<{ id: string }> };
export async function GET(_request: Request, context: RouteContext) {
if (!isDatabaseConfigured()) {
return dbUnavailable();
}
const { id } = await context.params;
const rule = await getPublicPublishedRuleById(id);
if (!rule) {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
return NextResponse.json({ rule });
}