|
3 | 3 | import { GetObjectCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3"; |
4 | 4 | import { VaccineTypes } from "@src/models/vaccine"; |
5 | 5 | import { VaccineContentPaths, vaccineTypeToPath } from "@src/services/content-api/constants"; |
| 6 | +import { ReadingS3Error, S3HttpStatusError, S3NoSuchKeyError } from "@src/services/content-api/gateway/exceptions"; |
6 | 7 | import { getFilteredContentForVaccine } from "@src/services/content-api/parsers/content-filter-service"; |
7 | 8 | import { getStyledContentForVaccine } from "@src/services/content-api/parsers/content-styling-service"; |
8 | 9 | import { |
9 | 10 | ContentErrorTypes, |
10 | 11 | GetContentForVaccineResponse, |
11 | 12 | StyledVaccineContent, |
12 | | - VaccinePageContent |
| 13 | + VaccinePageContent, |
13 | 14 | } from "@src/services/content-api/types"; |
14 | 15 | import { AppConfig, configProvider } from "@src/utils/config"; |
15 | 16 | import { AWS_PRIMARY_REGION } from "@src/utils/constants"; |
16 | 17 | import { logger } from "@src/utils/logger"; |
17 | 18 | import { S3_PREFIX, isS3Path } from "@src/utils/path"; |
| 19 | +import { HttpStatusCode } from "axios"; |
18 | 20 | import { readFile } from "node:fs/promises"; |
19 | 21 | import { Logger } from "pino"; |
20 | 22 | import { Readable } from "stream"; |
21 | | -import { |
22 | | - ReadingS3Error, |
23 | | - S3NoSuchKeyError, |
24 | | - S3HttpStatusError, |
25 | | -} from "@src/services/content-api/gateway/exceptions"; |
26 | | -import { HttpStatusCode } from "axios"; |
27 | 23 |
|
28 | 24 | const log: Logger = logger.child({ module: "content-reader-service" }); |
29 | 25 |
|
30 | 26 | const _readFileS3 = async (bucket: string, key: string): Promise<string> => { |
31 | 27 | try { |
32 | 28 | const s3Client: S3Client = new S3Client({ |
33 | | - region: AWS_PRIMARY_REGION |
| 29 | + region: AWS_PRIMARY_REGION, |
34 | 30 | }); |
35 | 31 |
|
36 | 32 | const getObjectCommand: GetObjectCommand = new GetObjectCommand({ |
37 | 33 | Bucket: bucket, |
38 | | - Key: key |
| 34 | + Key: key, |
39 | 35 | }); |
40 | 36 | const { Body } = await s3Client.send(getObjectCommand); |
41 | 37 |
|
@@ -95,13 +91,13 @@ const getContentForVaccine = async (vaccineType: VaccineTypes): Promise<GetConte |
95 | 91 | if (error instanceof ReadingS3Error) { |
96 | 92 | return { |
97 | 93 | styledVaccineContent: undefined, |
98 | | - contentError: ContentErrorTypes.CONTENT_LOADING_ERROR |
| 94 | + contentError: ContentErrorTypes.CONTENT_LOADING_ERROR, |
99 | 95 | }; |
100 | 96 | } else { |
101 | 97 | log.error(error, `Error getting content for vaccine: ${vaccineType}`); |
102 | 98 | return { |
103 | 99 | styledVaccineContent: undefined, |
104 | | - contentError: ContentErrorTypes.CONTENT_LOADING_ERROR |
| 100 | + contentError: ContentErrorTypes.CONTENT_LOADING_ERROR, |
105 | 101 | }; |
106 | 102 | } |
107 | 103 | } |
|
0 commit comments