in lambda/recipes-responder/src/commandline-reindex.ts [31:66]
async function getQueryUri(
maybeCapiUri?: string,
maybeComposerId?: string,
maybeRecipeUid?: string,
): Promise<string> {
const capiBase =
process.env['STAGE'] == 'PROD'
? 'https://content.guardianapis.com'
: 'https://content.code.dev-guardianapis.com';
if (maybeRecipeUid) {
const indexEntry = await recipeByUID(maybeRecipeUid);
if (indexEntry) {
console.log(
`Recipe ${maybeRecipeUid} belongs to CAPI article ${indexEntry.capiArticleId}`,
);
return `${capiBase}/${indexEntry.capiArticleId}`;
} else {
throw new Error(
`Could not find a recipe with ID ${maybeRecipeUid}. Are you sure you are querying the right environment?`,
);
}
} else if (maybeCapiUri) {
if (maybeCapiUri.startsWith('http')) {
return maybeCapiUri;
} else {
return `${capiBase}/${maybeCapiUri}`;
}
} else if (maybeComposerId) {
return `${capiBase}/internal-code/composer/${maybeComposerId}`;
} else {
throw new Error(
'You must specify either recipe UID, capi URI or composer ID',
);
}
}