diff --git a/src/constants.ts b/src/constants.ts index 4ee8afc..19f0744 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -37,3 +37,5 @@ export const IMPORT_PROJECT_CRON_SCHEDULE = export const DESCRIPTION_SUMMARY_LENGTH = Number( process.env.DESCRIPTION_SUMMARY_LENGTH || 300 ); + +export const a = assertNotNull(process.env.AGORA_API_KEY); diff --git a/src/features/import-projects/rf/index.ts b/src/features/import-projects/rf/index.ts index d4dd308..8ea6496 100644 --- a/src/features/import-projects/rf/index.ts +++ b/src/features/import-projects/rf/index.ts @@ -1,3 +1,4 @@ +import { AGORA_API_KEY } from "../../../constants"; import { RF_API_URL } from "./constants"; import { saveBatchProjects } from "./helpers"; import { RfApiResponse, RfProjectInfo } from "./type"; @@ -8,9 +9,14 @@ export const fetchRFProjectsByRound = async (round: number) => { let hasNext = true; console.log( - `[${new Date().toISOString()}] - Fetching projects for round: ${round} - ${process.env.AGORA_API_KEY}` + `[${new Date().toISOString()}] - Fetching projects for round: ${round}` ); + if (!AGORA_API_KEY) { + console.error("AGORA_API_KEY is not set"); + return; + } + try { while (hasNext) { const response = await fetch( @@ -19,7 +25,7 @@ export const fetchRFProjectsByRound = async (round: number) => { method: "GET", headers: { "Content-Type": "application/json", - Authorization: `Bearer ${process.env.AGORA_API_KEY}`, + Authorization: `Bearer ${AGORA_API_KEY}`, }, } );