Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ export async function GET(request) {
// we can safely access user data here
const session = await getServerSession();

if (!session?.user) {
return NextResponse.json(
{ error: "Unauthorized - Please login to access this resource" },
{ status: 401 }
);
}

// Return user's favorite tweets from localStorage
// In a real app, this would fetch from a database
return NextResponse.json({
Expand All @@ -20,6 +27,13 @@ export async function GET(request) {
export async function POST(request) {
const session = await getServerSession();

if (!session?.user) {
return NextResponse.json(
{ error: "Unauthorized - Please login to access this resource" },
{ status: 401 }
);
}

try {
const body = await request.json();

Expand All @@ -41,6 +55,13 @@ export async function POST(request) {
export async function DELETE(request) {
const session = await getServerSession();

if (!session?.user) {
return NextResponse.json(
{ error: "Unauthorized - Please login to access this resource" },
{ status: 401 }
);
}

try {
const { searchParams } = new URL(request.url);
const tweetId = searchParams.get("tweetId");
Expand Down