diff --git a/src/config.js b/src/config.js index 1a77873dc..399e6fc40 100644 --- a/src/config.js +++ b/src/config.js @@ -289,3 +289,26 @@ export const SESSION_MAX_AGE = fromEnvOrConfig("SESSION_MAX_AGE", 30 * 24 * 60 * export const GROUPS_DATA_FILE = process.env.GROUPS_DATA_FILE ?? path.join(__basedir, "env", (PRODUCTION ? "production" : "testing"), "groups.json"); + + +/** + * Name of the S3 bucket to use for Nextstrain Groups storage. + * + * The layout of objects in the bucket will be like so: + * + * ${bucketName}/ + * ${groupName}/ + * group-logo.png + * group-overview.md + * datasets/ + * ${datasetName}.json + * ${datasetName}_${sidecarType}.json + * … + * narratives/ + * ${narrativeName}.md + * … + * + * @type {string} + * @default nextstrain-groups + */ +export const GROUPS_BUCKET = fromEnvOrConfig("GROUPS_BUCKET", "nextstrain-groups"); diff --git a/src/sources/groups.js b/src/sources/groups.js index b85813c63..4823a0dd9 100644 --- a/src/sources/groups.js +++ b/src/sources/groups.js @@ -3,6 +3,7 @@ import AWS from 'aws-sdk'; import { Buffer } from 'buffer'; import yamlFront from 'yaml-front-matter'; import * as authz from '../authz/index.js'; +import { GROUPS_BUCKET } from '../config.js'; import { fetch } from '../fetch.js'; import { Group } from '../groups.js'; import * as utils from '../utils/index.js'; @@ -10,7 +11,7 @@ import { Source, Dataset, Narrative } from './models.js'; const S3 = new AWS.S3(); -const BUCKET = "nextstrain-groups"; +const BUCKET = GROUPS_BUCKET; const DATASET_PREFIX = "datasets/"; const NARRATIVE_PREFIX = "narratives/";