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
5/**
6 * OpenAPI StockTransfers Endpoint
7 * GET /api/v1/openapi/stock-transfers/[id] - Get stock transfer details
8 */
9export async function GET(
10 request: NextRequest,
11 { params }: { params: Promise<{ id: string }> }
12) {
13 try {
14 const authData = await getStoredAuth();
15 if (!authData || !authData.authenticated) {
16 return NextResponse.json(
17 { error: 'Authentication required' },
18 { status: 401 }
19 );
20 }
21
22 const { searchParams } = new URL(request.url);
23 const queryParams: Record<string, string | number> = {};
24
25 const srcuid = searchParams.get('srcuid');
26 if (srcuid) queryParams.srcuid = parseInt(srcuid);
27
28 const transfer = await fieldpineServerApi.apiCall(
29 `/StockTransfers/${await params.then(p => p.id)}`,
30 {
31 params: queryParams,
32 cookie: authData.apiKey,
33 useOpenApi: true
34 }
35 );
36
37 return NextResponse.json({
38 success: true,
39 data: transfer,
40 source: 'openapi'
41 });
42
43 } catch (error) {
44 console.error('StockTransfers API error:', error);
45 return NextResponse.json(
46 { error: 'Failed to fetch stock transfer' },
47 { status: 500 }
48 );
49 }
50}