settings.defaults.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * decaffeinate suggestions:
  3. * DS207: Consider shorter variations of null checks
  4. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  5. */
  6. const http = require('http')
  7. http.globalAgent.maxSockets = 300
  8. const Settings = {
  9. internal: {
  10. docstore: {
  11. port: 3016,
  12. host: process.env.LISTEN_ADDRESS || 'localhost'
  13. }
  14. },
  15. mongo: {
  16. options: {
  17. useUnifiedTopology:
  18. (process.env.MONGO_USE_UNIFIED_TOPOLOGY || 'true') === 'true'
  19. }
  20. },
  21. docstore: {
  22. archiveOnSoftDelete: process.env.ARCHIVE_ON_SOFT_DELETE === 'true',
  23. backend: process.env.BACKEND || 's3',
  24. healthCheck: {
  25. project_id: process.env.HEALTH_CHECK_PROJECT_ID
  26. },
  27. bucket: process.env.BUCKET_NAME || process.env.AWS_BUCKET || 'bucket',
  28. gcs: {
  29. unlockBeforeDelete: process.env.GCS_UNLOCK_BEFORE_DELETE === 'true',
  30. deletedBucketSuffix: process.env.GCS_DELETED_BUCKET_SUFFIX,
  31. deleteConcurrency: parseInt(process.env.GCS_DELETE_CONCURRENCY) || 50
  32. }
  33. },
  34. max_doc_length: parseInt(process.env.MAX_DOC_LENGTH) || 2 * 1024 * 1024 // 2mb
  35. }
  36. if (process.env.MONGO_CONNECTION_STRING != null) {
  37. Settings.mongo.url = process.env.MONGO_CONNECTION_STRING
  38. } else if (process.env.MONGO_HOST != null) {
  39. Settings.mongo.url = `mongodb://${process.env.MONGO_HOST}/sharelatex`
  40. } else {
  41. Settings.mongo.url = 'mongodb://127.0.0.1/sharelatex'
  42. }
  43. if (
  44. process.env.AWS_ACCESS_KEY_ID != null &&
  45. process.env.AWS_SECRET_ACCESS_KEY != null &&
  46. process.env.AWS_BUCKET != null
  47. ) {
  48. Settings.docstore.s3 = {
  49. key: process.env.AWS_ACCESS_KEY_ID,
  50. secret: process.env.AWS_SECRET_ACCESS_KEY,
  51. bucket: process.env.AWS_BUCKET,
  52. endpoint: process.env.AWS_S3_ENDPOINT,
  53. pathStyle: process.env.AWS_S3_PATH_STYLE,
  54. partSize: parseInt(process.env.AWS_S3_PARTSIZE) || 100 * 1024 * 1024
  55. }
  56. }
  57. if (process.env.GCS_API_ENDPOINT) {
  58. Settings.docstore.gcs.endpoint = {
  59. apiEndpoint: process.env.GCS_API_ENDPOINT,
  60. apiScheme: process.env.GCS_API_SCHEME,
  61. projectId: process.env.GCS_PROJECT_ID
  62. }
  63. }
  64. if (process.env.FALLBACK_BACKEND) {
  65. Settings.docstore.fallback = {
  66. backend: process.env.FALLBACK_BACKEND,
  67. // mapping of bucket names on the fallback, to bucket names on the primary.
  68. // e.g. { myS3UserFilesBucketName: 'myGoogleUserFilesBucketName' }
  69. buckets: JSON.parse(process.env.FALLBACK_BUCKET_MAPPING || '{}'),
  70. copyOnMiss: process.env.COPY_ON_MISS === 'true'
  71. }
  72. }
  73. module.exports = Settings