EverydayTech Platform - Developer Reference
Complete Source Code Documentation - All Applications
Loading...
Searching...
No Matches
route.ts
Go to the documentation of this file.
1import { NextRequest, NextResponse } from 'next/server';
2import { fieldpineServerApi } from '@/lib/server/fieldpineApi';
3import { getStoredAuth } from '@/lib/server/auth';
4
5export async function GET(request: NextRequest) {
6 try {
7 // Verify authentication
8 const authData = await getStoredAuth();
9 if (!authData || !authData.authenticated) {
10 return NextResponse.json(
11 { error: 'Authentication required' },
12 { status: 401 }
13 );
14 }
15
16 const searchParams = request.nextUrl.searchParams;
17 const areas = searchParams.get('areas') || 'accounts,customers,other,products,staff,reference,security,technical';
18
19 const result = await fieldpineServerApi.buckApiCall({
20 "3": "retailmax.elink.advisor.eventlist",
21 "110": areas
22 }, authData.apiKey);
23
24 return NextResponse.json({
25 success: true,
26 data: result,
27 source: 'elink'
28 });
29 } catch (error: any) {
30 console.error('Advisor API error:', error);
31 return NextResponse.json(
32 { success: false, error: error.message || 'Failed to fetch advisor data' },
33 { status: 500 }
34 );
35 }
36}