|
| 1 | +var config = {}; |
| 2 | +config.development = { |
| 3 | + // Config for database, only support mysql. |
| 4 | + db: { |
| 5 | + username: process.env.MYSQL_USERNAME, |
| 6 | + password: process.env.MYSQL_PASSWORD, |
| 7 | + database: process.env.MYSQL_DATABASE, |
| 8 | + host: process.env.MYSQL_HOST, |
| 9 | + port: process.env.MYSQL_PORT || 3306, |
| 10 | + dialect: "mysql", |
| 11 | + logging: false, |
| 12 | + operatorsAliases: false, |
| 13 | + }, |
| 14 | + // Config for local storage when storageType value is "local". |
| 15 | + local: { |
| 16 | + // Binary files storage dir, Do not use tmpdir and it's public download dir. |
| 17 | + storageDir: process.env.STORAGE_DIR, |
| 18 | + // Binary files download host address which Code Push Server listen to. the files storage in storageDir. |
| 19 | + downloadUrl: process.env.DOWNLOAD_URL, |
| 20 | + // public static download spacename. |
| 21 | + public: '/download' |
| 22 | + }, |
| 23 | + jwt: { |
| 24 | + // Recommended: 63 random alpha-numeric characters |
| 25 | + // Generate using: https://www.grc.com/passwords.htm |
| 26 | + tokenSecret: 'INSERT_RANDOM_TOKEN_KEY' |
| 27 | + }, |
| 28 | + common: { |
| 29 | + /* |
| 30 | + * tryLoginTimes is control login error times to avoid force attack. |
| 31 | + * if value is 0, no limit for login auth, it may not safe for account. when it's a number, it means you can |
| 32 | + * try that times today. but it need config redis server. |
| 33 | + */ |
| 34 | + tryLoginTimes: 0, |
| 35 | + // CodePush Web(https://github.com/lisong/code-push-web) login address. |
| 36 | + //codePushWebUrl: "http://127.0.0.1:3001/login", |
| 37 | + // create patch updates's number. default value is 3 |
| 38 | + diffNums: 3, |
| 39 | + // data dir for caclulate diff files. it's optimization. |
| 40 | + dataDir: process.env.DATA_DIR, |
| 41 | + // storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3") |
| 42 | + storageType: "local", |
| 43 | + // options value is (true | false), when it's true, it will cache updateCheck results in redis. |
| 44 | + updateCheckCache: false, |
| 45 | + // options value is (true | false), when it's true, it will cache rollout results in redis |
| 46 | + rolloutClientUniqueIdCache: false, |
| 47 | + }, |
| 48 | + // Config for smtp email,register module need validate user email project source https://github.com/nodemailer/nodemailer |
| 49 | + smtpConfig:{ |
| 50 | + host: "smtp.aliyun.com", |
| 51 | + port: 465, |
| 52 | + secure: true, |
| 53 | + auth: { |
| 54 | + user: "", |
| 55 | + pass: "" |
| 56 | + } |
| 57 | + }, |
| 58 | + // Config for redis (register module, tryLoginTimes module) |
| 59 | + redis: { |
| 60 | + default: { |
| 61 | + host: "127.0.0.1", |
| 62 | + port: 6379, |
| 63 | + retry_strategy: function (options) { |
| 64 | + if (options.error.code === 'ECONNREFUSED') { |
| 65 | + // End reconnecting on a specific error and flush all commands with a individual error |
| 66 | + return new Error('The server refused the connection'); |
| 67 | + } |
| 68 | + if (options.total_retry_time > 1000 * 60 * 60) { |
| 69 | + // End reconnecting after a specific timeout and flush all commands with a individual error |
| 70 | + return new Error('Retry time exhausted'); |
| 71 | + } |
| 72 | + if (options.times_connected > 10) { |
| 73 | + // End reconnecting with built in error |
| 74 | + return undefined; |
| 75 | + } |
| 76 | + // reconnect after |
| 77 | + return Math.max(options.attempt * 100, 3000); |
| 78 | + } |
| 79 | + } |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +config.development.log4js = { |
| 84 | + appenders: {console: { type: 'console'}}, |
| 85 | + categories : { |
| 86 | + "default": { appenders: ['console'], level:'error'}, |
| 87 | + "startup": { appenders: ['console'], level:'info'}, |
| 88 | + "http": { appenders: ['console'], level:'info'} |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +config.production = Object.assign({}, config.development); |
| 93 | +module.exports = config; |
0 commit comments