first commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getBackend } from "@/lib/backend";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
export async function POST(req: NextRequest, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const channel = await getBackend().addMember(id, String(body.userId ?? ""));
|
||||
if (!channel) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
return NextResponse.json({ channel });
|
||||
}
|
||||
|
||||
export async function DELETE(req: NextRequest, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const channel = await getBackend().removeMember(id, String(body.userId ?? ""));
|
||||
if (!channel) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
return NextResponse.json({ channel });
|
||||
}
|
||||
Reference in New Issue
Block a user