Skip to content

Commit ca9072c

Browse files
committed
fix config
1 parent d1c20d4 commit ca9072c

File tree

5 files changed

+31
-67
lines changed

5 files changed

+31
-67
lines changed

app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ if (app.get('env') === 'development') {
4949

5050

5151

52-
if (_.get(config, 'common.storageType') == 'local'
52+
if (_.get(config, 'common.storageType') === 'local'
5353
&& _.get(config, 'local.storageDir')
5454
&& fs.existsSync(_.get(config, 'local.storageDir'))
5555
) {
56-
app.use('/download', express.static(_.get(config, 'local.storageDir')));
56+
app.use(_.get(config, 'local.public', '/download'), express.static(_.get(config, 'local.storageDir')));
5757
}
5858

5959
app.use('/', routes);

config/config.js

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,54 @@
11
var config = {};
22
config.development = {
3-
//数据库配置
3+
// Config for database, only support mysql.
44
db: {
55
username: "root",
66
password: null,
77
database: "codepush",
88
host: "127.0.0.1",
99
dialect: "mysql"
1010
},
11-
//七牛云存储配置 当storageType为qiniu时需要配置
11+
// Config for qiniu (http://www.qiniu.com/) cloud storage when storageType value is "qiniu".
1212
qiniu: {
1313
accessKey: "",
1414
secretKey: "",
1515
bucketName: "",
16-
downloadUrl: "" //文件下载域名地址
16+
downloadUrl: "" // Binary files download host address.
1717
},
18-
// conf for s3
18+
// Config for Amazon s3 (https://aws.amazon.com/cn/s3/) storage when storageType value is "s3".
1919
s3: {
2020
bucketName: process.env.BUCKET_NAME,
2121
region: process.env.REGION,
22-
downloadUrl: process.env.DOWNLOAD_URL,
22+
downloadUrl: process.env.DOWNLOAD_URL, // binary files download host address.
2323
},
24-
//文件存储在本地配置 当storageType为local时需要配置
24+
// Config for local storage when storageType value is "local".
2525
local: {
26+
// Binary files storage dir, Do not use tmpdir and it's public download dir.
2627
storageDir: "/Users/tablee/workspaces/storage",
27-
//文件下载地址 CodePush Server 地址 + '/download' download对应app.js里面的地址
28-
downloadUrl: "http://localhost:3000/download"
28+
// Binary files download host address which Code Push Server listen to. the files storage in storageDir.
29+
downloadUrl: "http://localhost:3000/download",
30+
// public static download spacename.
31+
public: '/download'
2932
},
3033
common: {
31-
//登录jwt签名密钥,必须更改,否则有安全隐患,可以使用随机生成的字符串
34+
// jwt sign secret for auth. you have to modify it for security. use random string instead it.
3235
loginSecret: "CodePushServer",
33-
//当天登录密码错误尝试次数,超过次数帐户将会锁定。0:表示无限制,可能会出现暴力破解。 大于0:必须开启redis服务。
36+
/*
37+
* tryLoginTimes is control login error times to avoid force attack.
38+
* if value is 0, no limit for login auth, it may not safe for account. when it's a number, it means you can
39+
* try that times today. but it need config redis server.
40+
*/
3441
tryLoginTimes: 0,
35-
//CodePush Web部署地址,也可以配置成CodePush Web地址
36-
//codePushWebUrl: "http://localhost:3001",
37-
//差异化更新版本生成数目 默认为3
42+
// CodePush Web(https://github.com/lisong/code-push-web) login address.
43+
//codePushWebUrl: "http://localhost:3001/login",
44+
// create patch updates's number. default value is 3
3845
diffNums: 3,
39-
//数据目录,优化选项
46+
// data dir for caclulate diff files. it's optimization.
4047
dataDir: "/Users/tablee/workspaces/data",
41-
//选择存储类型,目前支持local和qiniu配置
48+
//storageType which is your binary package files store. options value is ("local" | "qiniu" | "s3")
4249
storageType: "local"
4350
},
44-
//邮件配置,注册模块验证邮箱需要使用 参考https://github.com/nodemailer/nodemailer
51+
//config for smtp email,register module need validate user email project source https://github.com/nodemailer/nodemailer
4552
smtpConfig:{
4653
host: "smtp.mxhichina.com",
4754
port: 465,
@@ -51,7 +58,7 @@ config.development = {
5158
pass: ""
5259
}
5360
},
54-
//配置redis, 注册时需要, 登录限制密码出错次数
61+
//config for redis (register module, tryLoginTimes module)
5562
redis: {
5663
default: {
5764
host: "127.0.0.1",

config/config.test.js

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,62 +2,40 @@ var os = require('os');
22

33
var config = {};
44
config.test = {
5-
//数据库配置
65
db: {
76
username: "root",
87
password: null,
98
database: "codepush_test",
109
host: "127.0.0.1",
1110
dialect: "mysql"
1211
},
13-
//七牛云存储配置 当storageType为qiniu时需要配置
14-
qiniu: {
15-
accessKey: "",
16-
secretKey: "",
17-
bucketName: "",
18-
downloadUrl: "" //文件下载域名地址
19-
},
20-
//文件存储在本地配置 当storageType为local时需要配置
2112
local: {
2213
storageDir: os.tmpdir(),
23-
//文件下载地址 CodePush Server 地址 + '/download' download对应app.js里面的地址
24-
downloadUrl: "http://localhost:3000/download"
14+
downloadUrl: "http://localhost:3000/download",
15+
public: '/download'
2516
},
2617
common: {
27-
//登录jwt签名密钥,必须更改,否则有安全隐患,可以使用随机生成的字符串
2818
loginSecret: "CodePushServer",
29-
//当天登录密码错误尝试次数,超过次数帐户将会锁定。0:表示无限制,可能会出现暴力破解。 大于0:必须开启redis服务。
3019
tryLoginTimes: 10,
31-
//CodePush Web部署地址,也可以配置成CodePush Web地址
32-
//codePushWebUrl: "http://localhost:3001",
33-
//差异化更新版本生成数目 默认为3
3420
diffNums: 3,
35-
//数据目录,优化选项
3621
dataDir: os.tmpdir(),
37-
//选择存储类型,目前支持local和qiniu配置
3822
storageType: "local"
3923
},
40-
//邮件配置,注册模块验证邮箱需要使用 参考https://github.com/nodemailer/nodemailer
4124
smtpConfig: false,
42-
//配置redis, 注册时需要, 登录限制密码出错次数
4325
redis: {
4426
default: {
4527
host: "127.0.0.1",
4628
port: 6379,
4729
retry_strategy: function (options) {
4830
if (options.error.code === 'ECONNREFUSED') {
49-
// End reconnecting on a specific error and flush all commands with a individual error
5031
return new Error('The server refused the connection');
5132
}
5233
if (options.total_retry_time > 1000 * 60 * 60) {
53-
// End reconnecting after a specific timeout and flush all commands with a individual error
5434
return new Error('Retry time exhausted');
5535
}
5636
if (options.times_connected > 10) {
57-
// End reconnecting with built in error
5837
return undefined;
5938
}
60-
// reconnect after
6139
return Math.max(options.attempt * 100, 3000);
6240
}
6341
}

config/config.testwin.js

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,38 @@ var os = require('os');
22

33
var config = {};
44
config.test = {
5-
//数据库配置
65
db: {
76
username: "root",
87
password: "Password12!",
98
database: "codepush_test",
109
host: "127.0.0.1",
1110
dialect: "mysql"
1211
},
13-
//七牛云存储配置 当storageType为qiniu时需要配置
14-
qiniu: {
15-
accessKey: "",
16-
secretKey: "",
17-
bucketName: "",
18-
downloadUrl: "" //文件下载域名地址
19-
},
20-
//文件存储在本地配置 当storageType为local时需要配置
2112
local: {
2213
storageDir: os.tmpdir(),
23-
//文件下载地址 CodePush Server 地址 + '/download' download对应app.js里面的地址
24-
downloadUrl: "http://localhost:3000/download"
14+
downloadUrl: "http://localhost:3000/download",
15+
public: '/download'
2516
},
2617
common: {
27-
//登录jwt签名密钥,必须更改,否则有安全隐患,可以使用随机生成的字符串
2818
loginSecret: "CodePushServer",
29-
//当天登录密码错误尝试次数,超过次数帐户将会锁定。0:表示无限制,可能会出现暴力破解。 大于0:必须开启redis服务。
3019
tryLoginTimes: 10,
31-
//CodePush Web部署地址,也可以配置成CodePush Web地址
32-
//codePushWebUrl: "http://localhost:3001",
33-
//差异化更新版本生成数目 默认为3
3420
diffNums: 3,
35-
//数据目录,优化选项
3621
dataDir: os.tmpdir(),
37-
//选择存储类型,目前支持local和qiniu配置
3822
storageType: "local"
3923
},
40-
//邮件配置,注册模块验证邮箱需要使用 参考https://github.com/nodemailer/nodemailer
4124
smtpConfig: false,
42-
//配置redis, 注册时需要, 登录限制密码出错次数
4325
redis: {
4426
default: {
4527
host: "127.0.0.1",
4628
port: 6379,
4729
retry_strategy: function (options) {
4830
if (options.error.code === 'ECONNREFUSED') {
49-
// End reconnecting on a specific error and flush all commands with a individual error
5031
return new Error('The server refused the connection');
5132
}
5233
if (options.total_retry_time > 1000 * 60 * 60) {
53-
// End reconnecting after a specific timeout and flush all commands with a individual error
5434
return new Error('Retry time exhausted');
5535
}
5636
if (options.times_connected > 10) {
57-
// End reconnecting with built in error
5837
return undefined;
5938
}
6039
// reconnect after

core/utils/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ var unzip = require('node-unzip-2');
66
var config = require('../config');
77
var _ = require('lodash');
88
var qiniu = require("qiniu");
9-
var AWS = require('aws-sdk');
109
var common = {};
1110
module.exports = common;
1211

@@ -191,6 +190,7 @@ common.uploadFileToQiniu = function (key, filePath) {
191190
};
192191

193192
common.uploadFileToS3 = function (key, filePath) {
193+
var AWS = require('aws-sdk');
194194
return (
195195
new Promise(function(resolve, reject) {
196196
AWS.config.update({

0 commit comments

Comments
 (0)