From ffe0783869f9872321dbb82c3f5ac55b7fd49549 Mon Sep 17 00:00:00 2001 From: BoHong Li Date: Mon, 2 Mar 2020 12:06:28 +0800 Subject: [PATCH] feat: old config and environment is not use anymore BREAKING CHANGE: remove old config and environment Signed-off-by: BoHong Li --- lib/config/hackmdEnvironment.js | 130 -------------------------------- lib/config/index.js | 3 - lib/config/oldDefault.js | 42 ----------- lib/config/oldEnvironment.js | 10 --- 4 files changed, 185 deletions(-) delete mode 100644 lib/config/hackmdEnvironment.js delete mode 100644 lib/config/oldDefault.js delete mode 100644 lib/config/oldEnvironment.js diff --git a/lib/config/hackmdEnvironment.js b/lib/config/hackmdEnvironment.js deleted file mode 100644 index 346a9c42..00000000 --- a/lib/config/hackmdEnvironment.js +++ /dev/null @@ -1,130 +0,0 @@ -'use strict' - -const { toBooleanConfig, toArrayConfig, toIntegerConfig } = require('./utils') - -module.exports = { - domain: process.env.HMD_DOMAIN, - urlPath: process.env.HMD_URL_PATH, - port: toIntegerConfig(process.env.HMD_PORT), - urlAddPort: toBooleanConfig(process.env.HMD_URL_ADDPORT), - useSSL: toBooleanConfig(process.env.HMD_USESSL), - hsts: { - enable: toBooleanConfig(process.env.HMD_HSTS_ENABLE), - maxAgeSeconds: toIntegerConfig(process.env.HMD_HSTS_MAX_AGE), - includeSubdomains: toBooleanConfig(process.env.HMD_HSTS_INCLUDE_SUBDOMAINS), - preload: toBooleanConfig(process.env.HMD_HSTS_PRELOAD) - }, - csp: { - enable: toBooleanConfig(process.env.HMD_CSP_ENABLE), - reportURI: process.env.HMD_CSP_REPORTURI - }, - protocolUseSSL: toBooleanConfig(process.env.HMD_PROTOCOL_USESSL), - allowOrigin: toArrayConfig(process.env.HMD_ALLOW_ORIGIN), - useCDN: toBooleanConfig(process.env.HMD_USECDN), - allowAnonymous: toBooleanConfig(process.env.HMD_ALLOW_ANONYMOUS), - allowAnonymousEdits: toBooleanConfig(process.env.HMD_ALLOW_ANONYMOUS_EDITS), - allowFreeURL: toBooleanConfig(process.env.HMD_ALLOW_FREEURL), - defaultPermission: process.env.HMD_DEFAULT_PERMISSION, - dbURL: process.env.HMD_DB_URL, - sessionSecret: process.env.HMD_SESSION_SECRET, - sessionLife: toIntegerConfig(process.env.HMD_SESSION_LIFE), - responseMaxLag: toIntegerConfig(process.env.HMD_RESPONSE_MAX_LAG), - imageUploadType: process.env.HMD_IMAGE_UPLOAD_TYPE, - imgur: { - clientID: process.env.HMD_IMGUR_CLIENTID - }, - s3: { - accessKeyId: process.env.HMD_S3_ACCESS_KEY_ID, - secretAccessKey: process.env.HMD_S3_SECRET_ACCESS_KEY, - region: process.env.HMD_S3_REGION - }, - minio: { - accessKey: process.env.HMD_MINIO_ACCESS_KEY, - secretKey: process.env.HMD_MINIO_SECRET_KEY, - endPoint: process.env.HMD_MINIO_ENDPOINT, - secure: toBooleanConfig(process.env.HMD_MINIO_SECURE), - port: toIntegerConfig(process.env.HMD_MINIO_PORT) - }, - s3bucket: process.env.HMD_S3_BUCKET, - azure: { - connectionString: process.env.HMD_AZURE_CONNECTION_STRING, - container: process.env.HMD_AZURE_CONTAINER - }, - facebook: { - clientID: process.env.HMD_FACEBOOK_CLIENTID, - clientSecret: process.env.HMD_FACEBOOK_CLIENTSECRET - }, - twitter: { - consumerKey: process.env.HMD_TWITTER_CONSUMERKEY, - consumerSecret: process.env.HMD_TWITTER_CONSUMERSECRET - }, - github: { - clientID: process.env.HMD_GITHUB_CLIENTID, - clientSecret: process.env.HMD_GITHUB_CLIENTSECRET - }, - bitbucket: { - clientID: process.env.HMD_BITBUCKET_CLIENTID, - clientSecret: process.env.HMD_BITBUCKET_CLIENTSECRET - }, - gitlab: { - baseURL: process.env.HMD_GITLAB_BASEURL, - clientID: process.env.HMD_GITLAB_CLIENTID, - clientSecret: process.env.HMD_GITLAB_CLIENTSECRET, - scope: process.env.HMD_GITLAB_SCOPE - }, - mattermost: { - baseURL: process.env.HMD_MATTERMOST_BASEURL, - clientID: process.env.HMD_MATTERMOST_CLIENTID, - clientSecret: process.env.HMD_MATTERMOST_CLIENTSECRET - }, - oauth2: { - baseURL: process.env.HMD_OAUTH2_BASEURL, - userProfileURL: process.env.HMD_OAUTH2_USER_PROFILE_URL, - userProfileUsernameAttr: process.env.HMD_OAUTH2_USER_PROFILE_USERNAME_ATTR, - userProfileDisplayNameAttr: process.env.HMD_OAUTH2_USER_PROFILE_DISPLAY_NAME_ATTR, - userProfileEmailAttr: process.env.HMD_OAUTH2_USER_PROFILE_EMAIL_ATTR, - tokenURL: process.env.HMD_OAUTH2_TOKEN_URL, - authorizationURL: process.env.HMD_OAUTH2_AUTHORIZATION_URL, - clientID: process.env.HMD_OAUTH2_CLIENT_ID, - clientSecret: process.env.HMD_OAUTH2_CLIENT_SECRET - }, - dropbox: { - clientID: process.env.HMD_DROPBOX_CLIENTID, - clientSecret: process.env.HMD_DROPBOX_CLIENTSECRET, - appKey: process.env.HMD_DROPBOX_APPKEY - }, - google: { - clientID: process.env.HMD_GOOGLE_CLIENTID, - clientSecret: process.env.HMD_GOOGLE_CLIENTSECRET - }, - ldap: { - providerName: process.env.HMD_LDAP_PROVIDERNAME, - url: process.env.HMD_LDAP_URL, - bindDn: process.env.HMD_LDAP_BINDDN, - bindCredentials: process.env.HMD_LDAP_BINDCREDENTIALS, - searchBase: process.env.HMD_LDAP_SEARCHBASE, - searchFilter: process.env.HMD_LDAP_SEARCHFILTER, - searchAttributes: toArrayConfig(process.env.HMD_LDAP_SEARCHATTRIBUTES), - usernameField: process.env.HMD_LDAP_USERNAMEFIELD, - useridField: process.env.HMD_LDAP_USERIDFIELD, - tlsca: process.env.HMD_LDAP_TLS_CA - }, - saml: { - idpSsoUrl: process.env.HMD_SAML_IDPSSOURL, - idpCert: process.env.HMD_SAML_IDPCERT, - issuer: process.env.HMD_SAML_ISSUER, - identifierFormat: process.env.HMD_SAML_IDENTIFIERFORMAT, - disableRequestedAuthnContext: toBooleanConfig(process.env.HMD_SAML_DISABLEREQUESTEDAUTHNCONTEXT), - groupAttribute: process.env.HMD_SAML_GROUPATTRIBUTE, - externalGroups: toArrayConfig(process.env.HMD_SAML_EXTERNALGROUPS, '|', []), - requiredGroups: toArrayConfig(process.env.HMD_SAML_REQUIREDGROUPS, '|', []), - attribute: { - id: process.env.HMD_SAML_ATTRIBUTE_ID, - username: process.env.HMD_SAML_ATTRIBUTE_USERNAME, - email: process.env.HMD_SAML_ATTRIBUTE_EMAIL - } - }, - email: toBooleanConfig(process.env.HMD_EMAIL), - allowEmailRegister: toBooleanConfig(process.env.HMD_ALLOW_EMAIL_REGISTER), - allowPDFExport: toBooleanConfig(process.env.HMD_ALLOW_PDF_EXPORT) -} diff --git a/lib/config/index.js b/lib/config/index.js index 325746f8..7ea0ae79 100644 --- a/lib/config/index.js +++ b/lib/config/index.js @@ -36,12 +36,9 @@ const fileConfig = fs.existsSync(configFilePath) ? require(configFilePath)[env] let config = require('./default') merge(config, require('./defaultSSL')) -merge(config, require('./oldDefault')) merge(config, debugConfig) merge(config, packageConfig) merge(config, fileConfig) -merge(config, require('./oldEnvironment')) -merge(config, require('./hackmdEnvironment')) merge(config, require('./environment')) merge(config, require('./dockerSecret')) diff --git a/lib/config/oldDefault.js b/lib/config/oldDefault.js deleted file mode 100644 index 90942951..00000000 --- a/lib/config/oldDefault.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict' - -module.exports = { - urlpath: undefined, - urladdport: undefined, - alloworigin: undefined, - usessl: undefined, - protocolusessl: undefined, - usecdn: undefined, - allowanonymous: undefined, - allowanonymousedits: undefined, - allowfreeurl: undefined, - defaultpermission: undefined, - dburl: undefined, - // ssl path - sslkeypath: undefined, - sslcertpath: undefined, - sslcapath: undefined, - dhparampath: undefined, - // other path - tmppath: undefined, - defaultnotepath: undefined, - docspath: undefined, - indexpath: undefined, - hackmdpath: undefined, - errorpath: undefined, - prettypath: undefined, - slidepath: undefined, - // session - sessionname: undefined, - sessionsecret: undefined, - sessionlife: undefined, - staticcachetime: undefined, - // socket.io - heartbeatinterval: undefined, - heartbeattimeout: undefined, - // document - documentmaxlength: undefined, - imageuploadtype: undefined, - allowemailregister: undefined, - allowpdfexport: undefined -} diff --git a/lib/config/oldEnvironment.js b/lib/config/oldEnvironment.js deleted file mode 100644 index 06047553..00000000 --- a/lib/config/oldEnvironment.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' - -const { toBooleanConfig } = require('./utils') - -module.exports = { - debug: toBooleanConfig(process.env.DEBUG), - dburl: process.env.DATABASE_URL, - urlpath: process.env.URL_PATH, - port: process.env.PORT -}