first commit

This commit is contained in:
2026-07-17 21:48:37 +05:30
commit f85599dac5
124 changed files with 10775 additions and 0 deletions
@@ -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 });
}
@@ -0,0 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
import { getBackend } from "@/lib/backend";
export const dynamic = "force-dynamic";
export async function POST(
_req: NextRequest,
{ params }: { params: Promise<{ id: string; messageId: string }> },
) {
const { id, messageId } = await params;
const message = await getBackend().pin(id, messageId);
if (!message) return NextResponse.json({ error: "not found" }, { status: 404 });
return NextResponse.json({ message });
}
@@ -0,0 +1,15 @@
import { NextRequest, NextResponse } from "next/server";
import { getBackend } from "@/lib/backend";
export const dynamic = "force-dynamic";
export async function POST(
req: NextRequest,
{ params }: { params: Promise<{ id: string; messageId: string }> },
) {
const { id, messageId } = await params;
const body = await req.json().catch(() => ({}));
const message = await getBackend().react(id, messageId, String(body.emoji ?? "👍"));
if (!message) return NextResponse.json({ error: "not found" }, { status: 404 });
return NextResponse.json({ message });
}
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from "next/server";
import { getBackend } from "@/lib/backend";
export const dynamic = "force-dynamic";
type Params = { params: Promise<{ id: string; messageId: string }> };
export async function PATCH(req: NextRequest, { params }: Params) {
const { id, messageId } = await params;
const body = await req.json().catch(() => ({}));
const message = await getBackend().editMessage(id, messageId, String(body.body ?? ""));
if (!message) return NextResponse.json({ error: "not found" }, { status: 404 });
return NextResponse.json({ message });
}
export async function DELETE(_req: NextRequest, { params }: Params) {
const { id, messageId } = await params;
const r = await getBackend().deleteMessage(id, messageId);
return NextResponse.json(r);
}
@@ -0,0 +1,14 @@
import { NextRequest, NextResponse } from "next/server";
import { getBackend } from "@/lib/backend";
export const dynamic = "force-dynamic";
export async function POST(
_req: NextRequest,
{ params }: { params: Promise<{ id: string; messageId: string }> },
) {
const { id, messageId } = await params;
const message = await getBackend().save(id, messageId);
if (!message) return NextResponse.json({ error: "not found" }, { status: 404 });
return NextResponse.json({ message });
}
@@ -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 });
}
@@ -0,0 +1,10 @@
import { NextRequest, NextResponse } from "next/server";
import { getBackend } from "@/lib/backend";
export const dynamic = "force-dynamic";
export async function POST(_req: NextRequest, { params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
const channel = await getBackend().markRead(id);
return NextResponse.json({ channel });
}
@@ -0,0 +1,12 @@
import { NextRequest, NextResponse } from "next/server";
import { getBackend } from "@/lib/backend";
export const dynamic = "force-dynamic";
export async function GET(
_req: NextRequest,
{ params }: { params: Promise<{ id: string; parentId: string }> },
) {
const { id, parentId } = await params;
return NextResponse.json(await getBackend().thread(id, parentId));
}
+20
View File
@@ -0,0 +1,20 @@
import { NextRequest, NextResponse } from "next/server";
import { getBackend } from "@/lib/backend";
export const dynamic = "force-dynamic";
export async function GET() {
return NextResponse.json({ channels: await getBackend().listChannels() });
}
// POST /api/bff/channels — create a channel or DM
export async function POST(req: NextRequest) {
const body = await req.json().catch(() => ({}));
const channel = await getBackend().createChannel({
name: String(body.name ?? "new-channel"),
kind: body.kind,
topic: body.topic,
memberIds: body.memberIds,
});
return NextResponse.json({ channel }, { status: 201 });
}