export async function validateCurationData()

in lambda/publish-todays-curation/src/curation.ts [122:159]


export async function validateCurationData(
	region: string,
	variant: string,
	date: Date,
	staticBucketName: string,
): Promise<CurationPath | null> {
	console.debug(`Checking path `, generatePath(region, variant, date));
	const req = new HeadObjectCommand({
		Bucket: staticBucketName,
		Key: generatePath(region, variant, date),
	});

	try {
		await s3Client.send(req); //this should throw an exception if the file does not exist
		console.debug(
			`Found curation data for ${region}/${variant} on ${formatISO(date)}`,
		);
		return {
			front: variant,
			edition: region,
			year: date.getFullYear(),
			month: date.getMonth() + 1,
			day: date.getDate(),
		};
	} catch (err) {
		if (err instanceof NotFound) {
			console.debug(
				`Did not find curation data for ${region}/${variant} on ${formatISO(
					date,
				)}`,
			);
			return null;
		} else {
			console.error(err);
			throw err;
		}
	}
}