Skip to content

Commit

Permalink
Making data bucket an env var
Browse files Browse the repository at this point in the history
  • Loading branch information
jim-sheldon committed Apr 26, 2022
1 parent d67e266 commit db7c3c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions verification/curator-service/api/src/controllers/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const defaultOutputQuery =
export default class CasesController {
constructor(
private readonly dataServerURL: string,
private readonly dataBucket: string,
private readonly s3Client: AWS.S3,
) {}

Expand Down Expand Up @@ -248,7 +249,7 @@ export default class CasesController {
const filename = `${country}.${format}.gz`;
const filepath = `${format}/${filename}`;
const params = {
Bucket: 'covid-19-country-export',
Bucket: this.dataBucket,
Key: filepath,
Expires: 5 * 60,
ResponseContentDisposition:
Expand Down Expand Up @@ -305,7 +306,7 @@ export default class CasesController {
const filepath = `${format}/${country}.${format}.gz`;
const contains = await this.s3Client
.headObject({
Bucket: 'covid-19-country-export',
Bucket: this.dataBucket,
Key: filepath,
})
.promise()
Expand Down
2 changes: 1 addition & 1 deletion verification/curator-service/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ async function makeApp() {
);

// Configure cases controller proxying to data service.
const casesController = new CasesController(env.DATASERVER_URL, s3Client);
const casesController = new CasesController(env.DATASERVER_URL, env.DATA_BUCKET, s3Client);
apiRouter.get(
'/cases',
authenticateByAPIKey,
Expand Down
5 changes: 5 additions & 0 deletions verification/curator-service/api/src/util/validate-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function validateEnv(): Readonly<{
AWS_SECRET_ACCESS_KEY: string;
AWS_SERVICE_REGION: string;
CURATOR_VERSION: string;
DATA_BUCKET: string;
DATASERVER_URL: string;
DB_CONNECTION_STRING: string;
EMAIL_USER_ADDRESS: string;
Expand Down Expand Up @@ -48,6 +49,10 @@ export default function validateEnv(): Readonly<{
desc: 'version string to display in UI for bug reports etc.',
devDefault: '(local testing)',
}),
DATA_BUCKET: str({
desc: 'S3 bucket containing case data',
devDefault: 'covid-19-country-export-dev-eu',
}),
DATASERVER_URL: url({
desc: 'URL at which to make requests to the data-service API',
devDefault: 'http://localhost:3000',
Expand Down

0 comments on commit db7c3c5

Please sign in to comment.