Newer
Older
import { authOptions } from "@/lib/auth";
import { prisma } from "@/lib/db";
import { getServerSession } from "next-auth/next";
import { revalidatePath } from "next/cache";
import { NextRequest, NextResponse } from "next/server";
type post = Prisma.PostUncheckedCreateInput
const session = await getServerSession(authOptions);
if (!session) {
return NextResponse.json({ status: 401 });
}
const userId = session.user.id
console.log("router data: " + data.content, "status:")
content: data.content,
userId: parseInt(userId),
published: true
}
const path = req.nextUrl.searchParams.get('path') || '/';
revalidatePath(path);
return NextResponse.json({ status: 201, message: 'Message Created' })
} catch (error) {
console.log("fail" + error);
}
console.log("post")

DESKTOP-9FO96TP\hehexd
committed
}
export async function GET(req: NextRequest, res: NextResponse) {
try {
const data = await req.json()
console.log("router data: " + data, "status:")
} catch (error) {

DESKTOP-9FO96TP\hehexd
committed
try {

DESKTOP-9FO96TP\hehexd
committed
}
})
return NextResponse.json({ status: 200, messages: messages })
} catch (error) {
console.log("fail" + error);
// res.status(400)
}
console.log("get")