import assert from 'node:assert/strict'; import fs from 'node:fs'; const read = file => fs.readFileSync(file, 'utf8').replace(/\r\n/g, '\n'); const legacyBridge = read('apps/api/src/nest/legacy-bridge.ts'); const server = read('apps/api/src/server.ts'); const worker = read('apps/worker/src/index.ts'); const workerModule = read('apps/worker/src/worker.module.ts'); const nativeKeys = [...legacyBridge.matchAll(/'(GET|POST|PUT|PATCH|DELETE) ([^']+)'/g)] .map(match => `${match[1]} ${match[2]}`); assert.equal(new Set(nativeKeys).size, 50, 'the first NestJS batch must own exactly 50 unique routes'); assert.equal(nativeKeys.length, 50, 'native route declarations must not contain duplicates'); assert.match(legacyBridge, /definitions\.filter\(\(\[method, path\]\) => !NATIVE_ROUTE_KEYS\.has/); assert.match(legacyBridge, /\/api\/questions\/:questionId\/videos/); assert.match(server, /NestFactory\.create<.*NestFastifyApplication>/); assert.match(server, /registerLegacyRoutes/); assert.match(server, /if \(!config\.isProduction\) registerOpenApi/); assert.match(server, /ApiEnvelopeInterceptor/); assert.match(server, /ApiExceptionFilter/); assert.match(worker, /NestFactory\.createApplicationContext\(WorkerModule/); assert.match(worker, /app\.get\(WorkerRunner\)/); assert.match(workerModule, /constructor\(private readonly jobs: WorkerJobRegistry, private readonly intervals: WorkerPollIntervals\)/); assert.match(workerModule, /constructor\(private readonly closers: WorkerCloserRegistry\)/); console.log('[PASS] NestJS first-batch routes, legacy bridge, docs guard and worker DI contract');