1 | var os = require('os');
|
2 |
|
3 | var config = {};
|
4 | config.development = {
|
5 | // Config for database, only support mysql.
|
6 | db: {
|
7 | username: process.env.RDS_USERNAME || "root",
|
8 | password: process.env.RDS_PASSWORD || null,
|
9 | database: process.env.DATA_BASE || "codepush",
|
10 | host: process.env.RDS_HOST || "127.0.0.1",
|
11 | port: process.env.RDS_PORT || 3306,
|
12 | dialect: "mysql",
|
13 | logging: false,
|
14 | operatorsAliases: false,
|
15 | },
|
16 | // Config for qiniu (http://www.qiniu.com/) cloud storage when storageType value is "qiniu".
|
17 | qiniu: {
|
18 | accessKey: "",
|
19 | secretKey: "",
|
20 | bucketName: "",
|
21 | downloadUrl: "" // Binary files download host address.
|
22 | },
|
23 | // Config for Amazon s3 (https://aws.amazon.com/cn/s3/) storage when storageType value is "s3".
|
24 | s3: {
|
25 | accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
26 | secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
27 | sessionToken: process.env.AWS_SESSION_TOKEN, //(optional)
|
28 | bucketName: process.env.BUCKET_NAME,
|
29 | region: process.env.REGION,
|
30 | downloadUrl: process.env.DOWNLOAD_URL, // binary files download host address.
|
31 | },
|
32 | // Config for Aliyun OSS (https://www.aliyun.com/product/oss) when storageType value is "oss".
|
33 | oss: {
|
34 | accessKeyId: "",
|
35 | secretAccessKey: "",
|
36 | endpoint: "",
|
37 | bucketName: "",
|
38 | prefix: "", // Key prefix in object key
|
39 | downloadUrl: "", // binary files download host address.
|
40 | },
|
41 | // Config for local storage when storageType value is "local".
|
42 | local: {
|
43 | // Binary files storage dir, Do not use tmpdir and it's public download dir.
|
44 | storageDir: process.env.STORAGE_DIR || "/Users/tablee/workspaces/storage",
|
45 | // Binary files download host address which Code Push Server listen to. the files storage in storageDir.
|
46 | downloadUrl: process.env.LOCAL_DOWNLOAD_URL || "http://127.0.0.1:3000/download",
|
47 | // public static download spacename.
|
48 | public: process.env.PUBLIC || '/download'
|
49 | },
|
50 | jwt: {
|
51 | // Recommended: 63 random alpha-numeric characters
|
52 | // Generate using: https://www.grc.com/passwords.htm
|
53 | tokenSecret: process.env.TOKEN_SECRET ||'INSERT_RANDOM_TOKEN_KEY'
|
54 | },
|
55 | common: {
|
56 | /*
|
57 | * tryLoginTimes is control login error times to avoid force attack.
|
58 | * if value is 0, no limit for login auth, it may not safe for account. when it's a number, it means you can
|
59 | * try that times today. but it need config redis server.
|
60 | */
|
61 | tryLoginTimes: 0,
|
62 | // CodePush Web(https://github.com/lisong/code-push-web) login address.
|
63 | //codePushWebUrl: "http://127.0.0.1:3001/login",
|
64 | // create patch updates's number. default value is 3
|
65 | diffNums: 3,
|
66 | // data dir for caclulate diff files. it's optimization.
|
67 | dataDir: process.env.DATA_DIR || os.tmpdir(),
|
68 | // storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3")
|
69 | storageType: process.env.STORAGE_TYPE || "local",
|
70 | // options value is (true | false), when it's true, it will cache updateCheck results in redis.
|
71 | updateCheckCache: false,
|
72 | // options value is (true | false), when it's true, it will cache rollout results in redis
|
73 | rolloutClientUniqueIdCache: false,
|
74 | },
|
75 | // Config for smtp email,register module need validate user email project source https://github.com/nodemailer/nodemailer
|
76 | smtpConfig:{
|
77 | host: "smtp.aliyun.com",
|
78 | port: 465,
|
79 | secure: true,
|
80 | auth: {
|
81 | user: "",
|
82 | pass: ""
|
83 | }
|
84 | },
|
85 | // Config for redis (register module, tryLoginTimes module)
|
86 | redis: {
|
87 | default: {
|
88 | host: "127.0.0.1",
|
89 | port: 6379,
|
90 | retry_strategy: function (options) {
|
91 | if (options.error.code === 'ECONNREFUSED') {
|
92 | // End reconnecting on a specific error and flush all commands with a individual error
|
93 | return new Error('The server refused the connection');
|
94 | }
|
95 | if (options.total_retry_time > 1000 * 60 * 60) {
|
96 | // End reconnecting after a specific timeout and flush all commands with a individual error
|
97 | return new Error('Retry time exhausted');
|
98 | }
|
99 | if (options.times_connected > 10) {
|
100 | // End reconnecting with built in error
|
101 | return undefined;
|
102 | }
|
103 | // reconnect after
|
104 | return Math.max(options.attempt * 100, 3000);
|
105 | }
|
106 | }
|
107 | }
|
108 | }
|
109 |
|
110 | config.development.log4js = {
|
111 | appenders: {console: { type: 'console'}},
|
112 | categories : {
|
113 | "default": { appenders: ['console'], level:'error'},
|
114 | "startup": { appenders: ['console'], level:'info'},
|
115 | "http": { appenders: ['console'], level:'info'}
|
116 | }
|
117 | }
|
118 |
|
119 | config.production = Object.assign({}, config.development);
|
120 | module.exports = config;
|