2021-05-19 12:24:23 -04:00
|
|
|
/* eslint-disable
|
|
|
|
no-path-concat,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
2021-05-19 12:24:23 -04:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS207: Consider shorter variations of null checks
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
const Path = require("path");
|
|
|
|
|
|
|
|
// environment variables renamed for consistency
|
|
|
|
// use AWS_ACCESS_KEY_ID-style going forward
|
2021-05-19 12:24:23 -04:00
|
|
|
if (process.env.AWS_KEY && !process.env.AWS_ACCESS_KEY_ID) {
|
|
|
|
process.env.AWS_ACCESS_KEY_ID = process.env.AWS_KEY;
|
2021-05-19 12:24:23 -04:00
|
|
|
}
|
2021-05-19 12:24:23 -04:00
|
|
|
if (process.env.AWS_SECRET && !process.env.AWS_SECRET_ACCESS_KEY) {
|
|
|
|
process.env.AWS_SECRET_ACCESS_KEY = process.env.AWS_SECRET;
|
2021-05-19 12:24:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// pre-backend setting, fall back to old behaviour
|
2021-05-19 12:24:23 -04:00
|
|
|
if (process.env.BACKEND == null) {
|
|
|
|
if ((process.env.AWS_ACCESS_KEY_ID != null) || (process.env.S3_BUCKET_CREDENTIALS != null)) {
|
|
|
|
process.env.BACKEND = "s3";
|
|
|
|
process.env.USER_FILES_BUCKET_NAME = process.env.AWS_S3_USER_FILES_BUCKET_NAME;
|
|
|
|
process.env.TEMPLATE_FILES_BUCKET_NAME = process.env.AWS_S3_TEMPLATE_FILES_BUCKET_NAME;
|
|
|
|
process.env.PUBLIC_FILES_BUCKET_NAME = process.env.AWS_S3_PUBLIC_FILES_BUCKET_NAME;
|
2021-05-19 12:24:23 -04:00
|
|
|
} else {
|
2021-05-19 12:24:23 -04:00
|
|
|
process.env.BACKEND = "fs";
|
|
|
|
process.env.USER_FILES_BUCKET_NAME = Path.resolve(__dirname + "/../user_files");
|
|
|
|
process.env.TEMPLATE_FILES_BUCKET_NAME = Path.resolve(__dirname + "/../template_files");
|
|
|
|
process.env.PUBLIC_FILES_BUCKET_NAME = Path.resolve(__dirname + "/../public_files");
|
2021-05-19 12:24:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const settings = {
|
|
|
|
internal: {
|
|
|
|
filestore: {
|
|
|
|
port: 3009,
|
2021-05-19 12:24:23 -04:00
|
|
|
host: process.env.LISTEN_ADDRESS || "localhost"
|
2021-05-19 12:24:23 -04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
filestore: {
|
|
|
|
// Which backend persistor to use.
|
|
|
|
// Choices are
|
|
|
|
// s3 - Amazon S3
|
|
|
|
// fs - local filesystem
|
|
|
|
// gcs - Google Cloud Storage
|
2021-05-19 12:24:23 -04:00
|
|
|
backend: process.env.BACKEND,
|
2021-05-19 12:24:23 -04:00
|
|
|
|
|
|
|
gcs: {
|
2020-03-13 12:14:06 -04:00
|
|
|
endpoint:
|
2021-05-19 12:24:23 -04:00
|
|
|
process.env.GCS_API_ENDPOINT ?{
|
|
|
|
apiEndpoint: process.env.GCS_API_ENDPOINT,
|
|
|
|
apiScheme: process.env.GCS_API_SCHEME,
|
|
|
|
projectId: process.env.GCS_PROJECT_ID
|
2021-05-19 12:24:23 -04:00
|
|
|
} : undefined,
|
2021-05-19 12:24:23 -04:00
|
|
|
unlockBeforeDelete: process.env.GCS_UNLOCK_BEFORE_DELETE === "true", // unlock an event-based hold before deleting. default false
|
|
|
|
deletedBucketSuffix: process.env.GCS_DELETED_BUCKET_SUFFIX, // if present, copy file to another bucket on delete. default null
|
|
|
|
deleteConcurrency: parseInt(process.env.GCS_DELETE_CONCURRENCY) || 50,
|
|
|
|
signedUrlExpiryInMs: parseInt(process.env.LINK_EXPIRY_TIMEOUT || 60000)
|
2021-05-19 12:24:23 -04:00
|
|
|
},
|
2020-03-05 12:23:47 -05:00
|
|
|
|
2020-02-17 09:04:42 -05:00
|
|
|
s3:
|
2021-05-19 12:24:23 -04:00
|
|
|
(process.env.AWS_ACCESS_KEY_ID != null) || (process.env.S3_BUCKET_CREDENTIALS != null) ?{
|
|
|
|
key: process.env.AWS_ACCESS_KEY_ID,
|
|
|
|
secret: process.env.AWS_SECRET_ACCESS_KEY,
|
|
|
|
endpoint: process.env.AWS_S3_ENDPOINT,
|
|
|
|
pathStyle: process.env.AWS_S3_PATH_STYLE,
|
|
|
|
partSize: process.env.AWS_S3_PARTSIZE || (100 * 1024 * 1024),
|
|
|
|
bucketCreds: ((process.env.S3_BUCKET_CREDENTIALS != null) ? JSON.parse(process.env.S3_BUCKET_CREDENTIALS) : undefined)
|
2021-05-19 12:24:23 -04:00
|
|
|
} : undefined,
|
|
|
|
|
|
|
|
// GCS should be configured by the service account on the kubernetes pod. See GOOGLE_APPLICATION_CREDENTIALS,
|
|
|
|
// which will be picked up automatically.
|
|
|
|
|
|
|
|
stores: {
|
2021-05-19 12:24:23 -04:00
|
|
|
user_files: process.env.USER_FILES_BUCKET_NAME,
|
|
|
|
template_files: process.env.TEMPLATE_FILES_BUCKET_NAME,
|
|
|
|
public_files: process.env.PUBLIC_FILES_BUCKET_NAME
|
2021-05-19 12:24:23 -04:00
|
|
|
},
|
2020-02-17 09:04:42 -05:00
|
|
|
|
|
|
|
fallback:
|
2021-05-19 12:24:23 -04:00
|
|
|
(process.env.FALLBACK_BACKEND != null) ?{
|
|
|
|
backend: process.env.FALLBACK_BACKEND,
|
2021-05-19 12:24:23 -04:00
|
|
|
// mapping of bucket names on the fallback, to bucket names on the primary.
|
|
|
|
// e.g. { myS3UserFilesBucketName: 'myGoogleUserFilesBucketName' }
|
2021-05-19 12:24:23 -04:00
|
|
|
buckets: JSON.parse(process.env.FALLBACK_BUCKET_MAPPING || '{}'),
|
|
|
|
copyOnMiss: process.env.COPY_ON_MISS === 'true'
|
2021-05-19 12:24:23 -04:00
|
|
|
} : undefined,
|
|
|
|
|
2021-05-19 12:24:23 -04:00
|
|
|
allowRedirects: process.env.ALLOW_REDIRECTS === 'true'
|
2021-05-19 12:24:23 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
path: {
|
2014-05-17 16:01:48 -04:00
|
|
|
uploadFolder: Path.resolve(__dirname + "/../uploads")
|
2021-05-19 12:24:23 -04:00
|
|
|
},
|
2018-07-06 05:28:02 -04:00
|
|
|
|
2021-05-19 12:24:23 -04:00
|
|
|
commands: {
|
|
|
|
// Any commands to wrap the convert utility in, for example ["nice"], or ["firejail", "--profile=/etc/firejail/convert.profile"]
|
2016-05-09 06:37:35 -04:00
|
|
|
convertCommandPrefix: []
|
2021-05-19 12:24:23 -04:00
|
|
|
},
|
2014-05-17 16:01:48 -04:00
|
|
|
|
2021-05-19 12:24:23 -04:00
|
|
|
enableConversions: process.env.ENABLE_CONVERSIONS === 'true',
|
2018-03-23 11:26:38 -04:00
|
|
|
|
2021-05-19 12:24:23 -04:00
|
|
|
sentry: {
|
2019-03-05 12:20:16 -05:00
|
|
|
dsn: process.env.SENTRY_DSN
|
2021-05-19 12:24:23 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Filestore health check
|
|
|
|
// ----------------------
|
|
|
|
// Project and file details to check in persistor when calling /health_check
|
2021-05-19 12:24:23 -04:00
|
|
|
if ((process.env.HEALTH_CHECK_PROJECT_ID != null) && (process.env.HEALTH_CHECK_FILE_ID != null)) {
|
2021-05-19 12:24:23 -04:00
|
|
|
settings.health_check = {
|
2021-05-19 12:24:23 -04:00
|
|
|
project_id: process.env.HEALTH_CHECK_PROJECT_ID,
|
|
|
|
file_id: process.env.HEALTH_CHECK_FILE_ID
|
2021-05-19 12:24:23 -04:00
|
|
|
};
|
|
|
|
}
|
2018-03-23 11:26:38 -04:00
|
|
|
|
2021-05-19 12:24:23 -04:00
|
|
|
module.exports = settings;
|