first commit
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getBackend } from "@/lib/backend";
|
||||
import type { InboxState } from "@lynkd/messaging-inbox-sdk";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function PATCH(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string }> },
|
||||
) {
|
||||
const { id } = await params;
|
||||
const body = await req.json().catch(() => ({}));
|
||||
const item = await getBackend().patchInbox(id, (body.state as InboxState) ?? "DONE");
|
||||
if (!item) return NextResponse.json({ error: "not found" }, { status: 404 });
|
||||
return NextResponse.json({ item });
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getBackend } from "@/lib/backend";
|
||||
import type { InboxState } from "@lynkd/messaging-inbox-sdk";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(req: NextRequest) {
|
||||
const state = (req.nextUrl.searchParams.get("state") as InboxState | null) ?? undefined;
|
||||
return NextResponse.json({ items: await getBackend().listInbox(state) });
|
||||
}
|
||||
Reference in New Issue
Block a user