first commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
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 GET(_req: NextRequest, { params }: Params) {
|
||||
const { id } = await params;
|
||||
return NextResponse.json({ messages: await getBackend().channelMessages(id) });
|
||||
}
|
||||
|
||||
export async function POST(req: NextRequest, { params }: Params) {
|
||||
const { id } = await params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const message = await getBackend().send(id, String(body.body ?? ""), {
|
||||
parentId: body.parentId,
|
||||
scheduledFor: body.scheduledFor,
|
||||
attachments: body.attachments,
|
||||
threadRootId: body.threadRootId,
|
||||
});
|
||||
return NextResponse.json({ message }, { status: 201 });
|
||||
}
|
||||
Reference in New Issue
Block a user