Skip to content

Commit f4276a2

Browse files
committed
init
1 parent 75e3fc6 commit f4276a2

File tree

8 files changed

+42
-18
lines changed

8 files changed

+42
-18
lines changed

Procfile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
web: node app.js

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,6 @@ http://hi.baidu.com/tang_guangyao/item/302a9d1a9976c06ae65e0643
3333
数据库对应模块单元测试完成
3434

3535
加入async,对于需要多次回调查询数据库的进行重构
36+
37+
使用外网免费数据库https://app.mongohq.com
38+

app.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,18 @@ app.use(express.bodyParser({uploadDir:'./uploads'}));
2424
//app.use(express.bodyParser());
2525
app.use(express.methodOverride());
2626
app.use(express.cookieParser());
27+
// app.use(express.session({
28+
// secret: settings.cookieSecret,
29+
// key: settings.db,
30+
// cookie: {maxAge: 1000 * 60 * 60 * 24 * 30},//30 days
31+
// store: new MongoStore({
32+
// db: settings.db
33+
// })
34+
// }));
2735
app.use(express.session({
2836
secret: settings.cookieSecret,
29-
key: settings.db,
3037
cookie: {maxAge: 1000 * 60 * 60 * 24 * 30},//30 days
31-
store: new MongoStore({
32-
db: settings.db
33-
})
38+
url: settings.url
3439
}));
3540
//声明静态引用在前,路由规则在后
3641
app.use(express.static(path.join(__dirname, 'public')));

models/connect.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,17 @@
22
保持数据库一直连接,保存一个全局变量
33
*/
44

5-
var mongodb = require('./db');
5+
var mongodb = require('mongodb').Db;
6+
var settings = require('../settings');
67

7-
mongodb.open(function(err,db){
8-
global.db=db;
9-
});
8+
// var mongodb = require('./db'),
9+
// settings = require('../settings');
10+
11+
// mongodb.open(settings.url,function(err,db){
12+
// global.db=db;
13+
// });
1014

15+
16+
mongodb.connect(settings.url, function (err, db) {
17+
global.db=db;
18+
});

models/db.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
var settings = require('../settings'),
2-
Db = require('mongodb').Db,
3-
Connection = require('mongodb').Connection,
4-
Server = require('mongodb').Server;
1+
// var settings = require('../settings'),
2+
// Db = require('mongodb').Db,
3+
// Connection = require('mongodb').Connection,
4+
// Server = require('mongodb').Server;
5+
6+
// module.exports = new Db(settings.db, new Server(settings.host, Connection.DEFAULT_PORT, {}), {safe: true});
7+
58

6-
module.exports = new Db(settings.db, new Server(settings.host, Connection.DEFAULT_PORT, {}), {safe: true});

public/js/tgy/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function IndexCtrl($scope, $http, $templateCache) {
3737
//如果没有信息,就不请求
3838
return;
3939
}
40-
$scope.url = 'http://xueqiu.com/stock/quote.json?code='+stockCode+'&key=47bce5c74f&access_token=gbQtYjUWioQ9DQWGpDIREK&_=1386664870607&callback=JSON_CALLBACK';
40+
$scope.url = 'http://xueqiu.com/stock/quote.json?code='+stockCode+'&key=47bce5c74f&access_token=qPVhzoKJWIL1o3UCSgUfRK&_=1389259380479&callback=JSON_CALLBACK';
4141
$scope.code = null;
4242
$scope.response = null;
4343
$http({method: $scope.method, url: $scope.url, cache: $templateCache}).

public/js/tgy/sto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ function FetchCtrl($scope, $http, $templateCache) {
126126

127127
//定时获取实时数据
128128
$scope.method = 'JSONP';
129-
$scope.url = 'http://xueqiu.com/stock/quote.json?code='+pathUrl+'&access_token=gbQtYjUWioQ9DQWGpDIREK&_=1386664413850&callback=JSON_CALLBACK';
129+
$scope.url = 'http://xueqiu.com/stock/quote.json?code='+pathUrl+'&access_token=qPVhzoKJWIL1o3UCSgUfRK&_=1389259380479&callback=JSON_CALLBACK';
130130
$scope.code = null;
131131
$scope.response = null;
132132

settings.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
// module.exports = {
2+
// cookieSecret: 'myStock',
3+
// db: 'stock',
4+
// host: 'localhost'
5+
// };
6+
17
module.exports = {
28
cookieSecret: 'myStock',
3-
db: 'stock',
4-
host: 'localhost'
5-
};
9+
url: 'mongodb://stock:tangguangyao@widmore.mongohq.com:10000/stock'
10+
};

0 commit comments

Comments
 (0)