Initial commit - SaveTheMoment Atlas Basis-Setup
This commit is contained in:
30
app/api/email-sync/route.ts
Normal file
30
app/api/email-sync/route.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getServerSession } from 'next-auth';
|
||||
import { authOptions } from '@/lib/auth';
|
||||
import { emailSyncService } from '@/lib/email-sync';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const session = await getServerSession(authOptions);
|
||||
|
||||
if (!session || session.user.role !== 'ADMIN') {
|
||||
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 });
|
||||
}
|
||||
|
||||
const { locationId } = await request.json();
|
||||
|
||||
if (!locationId) {
|
||||
return NextResponse.json({ error: 'Location ID required' }, { status: 400 });
|
||||
}
|
||||
|
||||
const result = await emailSyncService.syncLocationEmails(locationId);
|
||||
|
||||
return NextResponse.json(result);
|
||||
} catch (error: any) {
|
||||
console.error('Email sync API error:', error);
|
||||
return NextResponse.json(
|
||||
{ error: error.message || 'Internal server error' },
|
||||
{ status: 500 }
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user