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 Stock2 Primitive Endpoint
7 * POST /api/v1/openapi/stock2/primitive
8 * Process stock primitive commands for low-level stock control
9 */
10export async function POST(request: NextRequest) {
11 try {
12 const authData = await getStoredAuth();
13 if (!authData || !authData.authenticated) {
14 return NextResponse.json(
15 { error: 'Authentication required' },
16 { status: 401 }
17 );
18 }
19
20 const body = await request.json();
21
22 const result = await fieldpineServerApi.apiCall("/Stock2/Primitive", {
23 method: 'POST',
24 body,
25 cookie: authData.apiKey,
26 useOpenApi: true
27 });
28
29 return NextResponse.json({
30 success: true,
31 data: result,
32 source: 'openapi'
33 });
34
35 } catch (error) {
36 console.error('Stock2 Primitive POST error:', error);
37 return NextResponse.json(
38 { error: 'Failed to process stock primitive' },
39 { status: 500 }
40 );
41 }
42}