Files
medreport_mrb2b/app/api/job/sync-analysis-groups-store/route.ts
Danel Kungla 17e7a98534 eslint fix
2025-10-07 18:43:42 +03:00

35 lines
903 B
TypeScript

import { NextRequest, NextResponse } from 'next/server';
import loadEnv from '../handler/load-env';
import syncAnalysisGroupsStore from '../handler/sync-analysis-groups-store';
import validateApiKey from '../handler/validate-api-key';
export const POST = async (request: NextRequest) => {
loadEnv();
try {
validateApiKey(request);
} catch {
return NextResponse.json({}, { status: 401, statusText: 'Unauthorized' });
}
try {
await syncAnalysisGroupsStore();
console.info('Successfully synced analysis groups store');
return NextResponse.json(
{
message: 'Successfully synced analysis groups store',
},
{ status: 200 },
);
} catch (e) {
console.error('Error syncing analysis groups store', e);
return NextResponse.json(
{
message: 'Failed to sync analysis groups store',
},
{ status: 500 },
);
}
};