|
| 1 | +import { |
| 2 | + deleteBenchmarkContract, |
| 3 | + getBenchmarkContract, |
| 4 | + updateBenchmarkContract, |
| 5 | +} from '@/lib/api/contracts/benchmarks' |
| 6 | +import { |
| 7 | + defineInternalJsonRoute, |
| 8 | + internalOrchestrationErrorPolicy, |
| 9 | + internalRateLimits, |
| 10 | + internalSessionAuth, |
| 11 | +} from '@/lib/api/server/routes' |
| 12 | +import { deleteBenchmark, getBenchmark, updateBenchmark } from '@/lib/benchmarks/application/cases' |
| 13 | +import { benchmarkOperations } from '@/lib/benchmarks/application/operations' |
| 14 | +import { requireBenchmarkEnabled } from '@/lib/benchmarks/config' |
| 15 | + |
| 16 | +export const GET = defineInternalJsonRoute({ |
| 17 | + contract: getBenchmarkContract, |
| 18 | + auth: internalSessionAuth, |
| 19 | + operation: benchmarkOperations.read, |
| 20 | + rateLimit: internalRateLimits.none({ |
| 21 | + reason: 'The owner polls bounded benchmark artifacts under current source access', |
| 22 | + }), |
| 23 | + errorPolicy: internalOrchestrationErrorPolicy, |
| 24 | + beforeParse: () => requireBenchmarkEnabled(), |
| 25 | + mapInput: ({ params }) => ({ organizationId: params.id, benchmarkId: params.benchmarkId }), |
| 26 | + useCase: getBenchmark, |
| 27 | +}) |
| 28 | + |
| 29 | +export const PATCH = defineInternalJsonRoute({ |
| 30 | + contract: updateBenchmarkContract, |
| 31 | + auth: internalSessionAuth, |
| 32 | + operation: benchmarkOperations.update, |
| 33 | + rateLimit: internalRateLimits.user({ bucketName: 'benchmark-update' }), |
| 34 | + errorPolicy: internalOrchestrationErrorPolicy, |
| 35 | + beforeParse: () => requireBenchmarkEnabled(), |
| 36 | + mapInput: ({ params, body: { version, ...patch } }) => ({ |
| 37 | + organizationId: params.id, |
| 38 | + benchmarkId: params.benchmarkId, |
| 39 | + version, |
| 40 | + patch, |
| 41 | + }), |
| 42 | + useCase: updateBenchmark, |
| 43 | +}) |
| 44 | + |
| 45 | +export const DELETE = defineInternalJsonRoute({ |
| 46 | + contract: deleteBenchmarkContract, |
| 47 | + auth: internalSessionAuth, |
| 48 | + operation: benchmarkOperations.delete, |
| 49 | + rateLimit: internalRateLimits.user({ bucketName: 'benchmark-delete' }), |
| 50 | + errorPolicy: internalOrchestrationErrorPolicy, |
| 51 | + beforeParse: () => requireBenchmarkEnabled(), |
| 52 | + mapInput: ({ params, body }) => ({ |
| 53 | + organizationId: params.id, |
| 54 | + benchmarkId: params.benchmarkId, |
| 55 | + version: body.version, |
| 56 | + }), |
| 57 | + useCase: deleteBenchmark, |
| 58 | +}) |
0 commit comments