async read()

in libs/newsletters-data-client/src/lib/layout-storage/S3LayoutStorage.ts [64:92]


	async read(
		edition: EditionId,
	): Promise<SuccessfulStorageResponse<Layout> | UnsuccessfulStorageResponse> {
		console.log('read', edition);

		try {
			const layout = await this.fetchLayout(edition);

			if (!layout) {
				return {
					ok: false,
					message: `failed to read layout with name '${edition}'`,
					reason: StorageRequestFailureReason.NotFound,
				};
			}

			return {
				ok: true,
				data: layout,
			};
		} catch (error) {
			console.error(error);
			return {
				ok: false,
				message: `failed to read layout for ${edition}`,
				reason: StorageRequestFailureReason.S3Failure,
			};
		}
	}