@@ -30,6 +30,7 @@ function parseArgs(argv) {
3030 scanMode : 'mock' ,
3131 mockFailUrl : [ ] ,
3232 outputRoot : null ,
33+ dapApiKey : undefined ,
3334 concurrency : 4 ,
3435 timeoutMs : 20000 ,
3536 maxRetries : 1
@@ -68,6 +69,9 @@ function parseArgs(argv) {
6869 case '--output-root' :
6970 args . outputRoot = argv [ ++ index ] ;
7071 break ;
72+ case '--dap-api-key' :
73+ args . dapApiKey = argv [ ++ index ] ;
74+ break ;
7175 case '--concurrency' :
7276 args . concurrency = Number ( argv [ ++ index ] ) ;
7377 break ;
@@ -234,6 +238,7 @@ export async function runDailyScan(inputArgs = parseArgs(process.argv)) {
234238 const args = inputArgs ;
235239 const repoRoot = path . resolve ( args . outputRoot ?? getDefaultRepoRoot ( ) ) ;
236240 const configPath = args . configPath ?? getDefaultConfigPath ( ) ;
241+ const dapApiKey = args . dapApiKey ?? process . env . DAP_API_KEY ;
237242
238243 let runMetadata ;
239244
@@ -251,11 +256,17 @@ export async function runDailyScan(inputArgs = parseArgs(process.argv)) {
251256 source : 'dap'
252257 } ) ;
253258
259+ const dapEndpoint = runtimeConfig . sources ?. dap_top_pages_endpoint ;
260+ if ( ! args . sourceFile && dapEndpoint ?. includes ( 'api.gsa.gov' ) && ! dapApiKey ) {
261+ throw new Error ( 'DAP_API_KEY is required to fetch top pages from api.gsa.gov. Set repo secret DAP_API_KEY or pass --dap-api-key.' ) ;
262+ }
263+
254264 const normalized = await getNormalizedTopPages ( {
255- endpoint : runtimeConfig . sources ?. dap_top_pages_endpoint ,
265+ endpoint : dapEndpoint ,
256266 sourceFile : args . sourceFile ,
257267 limit : runtimeConfig . scan . url_limit ,
258- sourceDate : runMetadata . run_date
268+ sourceDate : runMetadata . run_date ,
269+ dapApiKey
259270 } ) ;
260271
261272 const warningEvents = normalized . warnings . map ( ( warning ) =>
0 commit comments