35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import type {NextRequest} from 'next/server';
|
|
import {sitesApi} from '@/services/api/sitesApi';
|
|
import {proxyUpstream} from '@/shared/services/bff';
|
|
import {toCamera} from '@/features/stores/services/mapCamera';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
/**
|
|
* POST /api/cameras/{id}/check — ask the shop PC to prove this camera works.
|
|
*
|
|
* Two kinds: `connection` (can it be reached at all) and `placement` (is the
|
|
* view usable for recognition). Anything else the platform rejects, so the
|
|
* union is narrowed here rather than passed through as a free string.
|
|
*
|
|
* The platform answers 202 and the camera it returns still carries the PREVIOUS
|
|
* check — the edge has not run the new one yet. The caller re-reads; it must
|
|
* not render this response as the verdict.
|
|
*/
|
|
export async function POST(
|
|
req: NextRequest,
|
|
{params}: {params: Promise<{id: string}>},
|
|
) {
|
|
const {id} = await params;
|
|
return proxyUpstream(
|
|
req,
|
|
(token, body) =>
|
|
sitesApi.checkCamera(
|
|
token,
|
|
id,
|
|
body.kind === 'placement' ? 'placement' : 'connection',
|
|
),
|
|
{map: toCamera, status: 202},
|
|
);
|
|
}
|