feat: post saving, instant publish, scheduling, post history per channel

This commit is contained in:
Alexey Pavlov
2026-05-31 17:36:02 +03:00
parent e2b64baf2e
commit 1a1eac16ee
5 changed files with 262 additions and 2 deletions
+25
View File
@@ -0,0 +1,25 @@
import { NextResponse } from 'next/server';
import { requireUser } from '@/lib/session';
import { engine } from '@/lib/engine';
export async function GET(req) {
const user = await requireUser();
if (!user) return NextResponse.json({error:'Unauthorized'},{status:401});
const { searchParams } = new URL(req.url);
const params = {};
for (const [k,v] of searchParams) params[k] = v;
try {
const data = await engine.listUserPosts(user.id, params);
return NextResponse.json(data);
} catch (e) { return NextResponse.json({error:e.message},{status:500}); }
}
export async function POST(req) {
const user = await requireUser();
if (!user) return NextResponse.json({error:'Unauthorized'},{status:401});
const body = await req.json();
try {
const data = await engine.savePost(user.id, body);
return NextResponse.json(data);
} catch (e) { return NextResponse.json({error:e.message},{status:500}); }
}