Skip to content

Commit b818d95

Browse files
committed
fix config
1 parent bd70c87 commit b818d95

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ $ npm install
1717
$ vim config/config.json
1818
```
1919

20+
read [config.md](https://github.com/lisong/code-push-server/blob/master/docs/config.md)
21+
22+
2023
## Storage mode [local/qiniu]
2124

2225
## RUN
@@ -31,6 +34,8 @@ or point config file and ENV
3134
$ CONFIG_FILE=/path/to/config.json NODE_ENV=production node ./bin/www
3235
```
3336

37+
notice. you have to change `loginSecret` in config
38+
3439
## Default listen Host/Port 127.0.0.1/3000
3540
you can change like this.
3641

@@ -100,6 +105,21 @@ $ vim /path/to/production/process.yml #configure your env.
100105
$ pm2 start /path/to/production/process.yml
101106
```
102107

108+
## Use [CodePush Web](https://github.com/lisong/code-push-web) manage apps
109+
110+
add codePushWebUrl config in ./config/config.json
111+
112+
eg.
113+
114+
```json
115+
...
116+
"common": {
117+
"loginSecret": "CodePushServer",
118+
"codePushWebUrl": "Your CodePush Web address",
119+
}
120+
...
121+
```
122+
103123
## License
104124
MIT License [read](https://github.com/lisong/code-push-server/blob/master/LICENSE)
105125

config/config.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919
},
2020
"common": {
2121
"loginSecret": "CodePushServer",
22+
"codePushWebUrl": "",
2223
"diffNums": 3,
2324
"dataDir": "",
24-
"storageType": "qiniu"
25+
"storageType": "local",
2526
}
2627
},
2728
"production": {
@@ -44,9 +45,10 @@
4445
},
4546
"common": {
4647
"loginSecret": "CodePushServer",
48+
"codePushWebUrl": "",
4749
"diffNums": 3,
4850
"dataDir": "",
49-
"storageType": "qiniu"
51+
"storageType": "local"
5052
}
5153
}
5254
}

docs/config.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Config 解析
2+
3+
```json
4+
{
5+
"development": {
6+
#数据库配置
7+
"db": {
8+
"username": "root",
9+
"password": null,
10+
"database": "codepush",
11+
"host": "127.0.0.1",
12+
"dialect": "mysql" #目前只支持mysql
13+
},
14+
#七牛云存储配置 当storageType为qiniu时需要配置
15+
"qiniu": {
16+
"accessKey": "",
17+
"secretKey": "",
18+
"bucketName": "",
19+
"downloadUrl": "" #文件下载域名地址
20+
},
21+
#文件存储在本地配置 当storageType为local时需要配置
22+
"local": {
23+
"storageDir": "/Users/tablee/workspaces/storage", #文件存储目录
24+
#文件下载地址 CodePush Server 地址 + '/download' download对应app.js里面的地址
25+
"downloadUrl": "http://localhost:3000/download"
26+
},
27+
"common": {
28+
"loginSecret": "CodePushServer", #登录jwt签名密钥,必须更改,否则有安全隐患,可以随机生成字符串
29+
"codePushWebUrl": "", #CodePush Web部署地址,也可以配置成CodePush登录地址
30+
"diffNums": 3, #差异化更新版本生成数目 默认为3
31+
"dataDir": "", #数据目录,优化选项
32+
"storageType": "local", #选择存储类型,目前支持local和qiniu配置
33+
}
34+
},
35+
"production": {
36+
# 生产环境 和 development类似
37+
}
38+
}
39+
```

routes/auth.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ var security = require('../core/utils/security');
55
var accountManager = require('../core/services/account-manager')();
66

77
router.get('/login', function(req, res, next) {
8-
res.render('auth/login', { title: 'CodePushServer' });
8+
var config = require('../core/config');
9+
var codePushWebUrl = _.get(config, 'common.codePushWebUrl');
10+
var isRedirect = false;
11+
if (codePushWebUrl) {
12+
var validator = require('validator');
13+
if (validator.isUrl(codePushWebUrl)){
14+
isRedirect = true;
15+
}
16+
}
17+
if (isRedirect) {
18+
res.redirect(codePushWebUrl);
19+
} else {
20+
res.render('auth/login', { title: 'CodePushServer' });
21+
}
922
});
1023

1124
router.post('/logout', function (req, res, next) {

0 commit comments

Comments
 (0)