mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
refactor(config.js): Extract config file
* Separate different config source to each files * Freeze config object
This commit is contained in:
parent
4738ba7d36
commit
ecb0533605
15 changed files with 767 additions and 618 deletions
51
lib/config/dockerSecret.js
Normal file
51
lib/config/dockerSecret.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
'use strict'
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
const basePath = path.resolve('/var/run/secrets/')
|
||||
|
||||
function getSecret (secret) {
|
||||
const filePath = path.join(basePath, secret)
|
||||
if (fs.existsSync(filePath)) return fs.readFileSync(filePath)
|
||||
return undefined
|
||||
}
|
||||
|
||||
if (fs.existsSync(basePath)) {
|
||||
module.exports = {
|
||||
sessionsecret: getSecret('sessionsecret'),
|
||||
sslkeypath: getSecret('sslkeypath'),
|
||||
sslcertpath: getSecret('sslcertpath'),
|
||||
sslcapath: getSecret('sslcapath'),
|
||||
dhparampath: getSecret('dhparampath'),
|
||||
s3: {
|
||||
accessKeyId: getSecret('s3_acccessKeyId'),
|
||||
secretAccessKey: getSecret('s3_secretAccessKey')
|
||||
},
|
||||
facebook: {
|
||||
clientID: getSecret('facebook_clientID'),
|
||||
clientSecret: getSecret('facebook_clientSecret')
|
||||
},
|
||||
twitter: {
|
||||
consumerKey: getSecret('twitter_consumerKey'),
|
||||
consumerSecret: getSecret('twitter_consumerSecret')
|
||||
},
|
||||
github: {
|
||||
clientID: getSecret('github_clientID'),
|
||||
clientSecret: getSecret('github_clientSecret')
|
||||
},
|
||||
gitlab: {
|
||||
clientID: getSecret('gitlab_clientID'),
|
||||
clientSecret: getSecret('gitlab_clientSecret')
|
||||
},
|
||||
dropbox: {
|
||||
clientID: getSecret('dropbox_clientID'),
|
||||
clientSecret: getSecret('dropbox_clientSecret')
|
||||
},
|
||||
google: {
|
||||
clientID: getSecret('google_clientID'),
|
||||
clientSecret: getSecret('google_clientSecret')
|
||||
},
|
||||
imgur: getSecret('imgur_clientid')
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue