xonecas.io
556
Bn

bees-nest / files

bees-nest / src / app / api / domains / rules / route.ts

693 bytes
1import { eq } from "drizzle-orm";
2import { NextResponse } from "next/server";
3import { domains } from "@/db/schema";
4import { db } from "@/lib/db";
5
6export const dynamic = "force-dynamic";
7
8export async function GET(req: Request) {
9  const { searchParams } = new URL(req.url);
10  const domain = searchParams.get("domain");
11
12  if (!domain) {
13    return NextResponse.json({ error: "Domain required" }, { status: 400 });
14  }
15
16  const result = await db
17    .select()
18    .from(domains)
19    .where(eq(domains.domain, domain))
20    .limit(1);
21
22  if (result.length === 0) {
23    return NextResponse.json({ found: false });
24  }
25
26  return NextResponse.json({ found: true, rules: result[0].robotsTxt });
27}