feat(MED-131): move jobs to /api/job/* secured with key

This commit is contained in:
2025-08-04 11:51:11 +03:00
parent 5746e1b087
commit 43493c261c
12 changed files with 204 additions and 93 deletions

View File

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