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 { CWAGnapApi } from '@/lib/cwa-gnap-api';
3
4export async function GET(request: NextRequest) {
5 const api = new CWAGnapApi();
6
7 // Try to get API key from cookies or headers
8 const apiKey = request.cookies.get('FieldpineApiKey')?.value ||
9 request.headers.get('Authorization')?.replace('Bearer ', '');
10
11 if (apiKey) {
12 api.setApiKey(apiKey);
13 }
14
15 try {
16 const result = await api.getServerStatus();
17
18 if (result.error) {
19 return NextResponse.json(
20 { error: result.error },
21 { status: 500 }
22 );
23 }
24
25 return NextResponse.json(result);
26 } catch (error) {
27 console.error('API Error:', error);
28 return NextResponse.json(
29 { error: 'Internal server error' },
30 { status: 500 }
31 );
32 }
33}