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 const authData = await getStoredAuth();
8 if (!authData || !authData.authenticated) {
9 return NextResponse.json(
10 { error: 'Authentication required' },
11 { status: 401 }
12 );
13 }
14
15 try {
16 const buckParams: Record<string, string> = {
17 "3": "retailmax.elink.topology.list",
18 };
19
20 const topology = await fieldpineServerApi.buckApiCall(buckParams, authData.apiKey);
21
22 return NextResponse.json({
23 success: true,
24 data: topology,
25 source: 'elink'
26 });
27
28 } catch (error) {
29 console.error('eLink topology list error:', error);
30 return NextResponse.json(
31 { error: 'eLink endpoint unavailable', source: 'elink' },
32 { status: 503 }
33 );
34 }
35
36 } catch (error) {
37 console.error('eLink topology list error:', error);
38 return NextResponse.json(
39 { error: 'Failed to fetch topology' },
40 { status: 500 }
41 );
42 }
43}