Commit 9a60079 1 parent 606b492 commit 9a60079 Copy full SHA for 9a60079
File tree 3 files changed +15
-7
lines changed
3 files changed +15
-7
lines changed Original file line number Diff line number Diff line change 1
- const env = process . env . NODE_ENV || 'development' ;
1
+ const env = process . env . NODE_ENV ;
2
2
const port = 1244
3
+ const db = '/test'
3
4
let baseUrl = ''
4
- if ( env === 'development' ) {
5
- baseUrl = 'http ://127.0.0.1'
5
+ if ( env ) {
6
+ baseUrl = 'mongodb ://127.0.0.1:27017 '
6
7
} else {
7
- baseUrl = '待上线'
8
+ console . log ( '----------------------' )
9
+ baseUrl = 'mongodb://47.95.203.205:27017'
8
10
}
11
+ console . log ( baseUrl , '----------------------' )
9
12
module . exports = {
10
13
port,
11
- baseUrl
14
+ baseUrl,
15
+ db
12
16
}
Original file line number Diff line number Diff line change 1
1
// 用于定义数据表结构
2
2
const mongoose = require ( 'mongoose' )
3
+ const { baseUrl, port, db} = require ( './config' )
4
+ const url = baseUrl + db
5
+ console . log ( url )
3
6
mongoose . set ( 'strictQuery' , false ) ;
4
7
exports . connect = ( ) => {
5
- mongoose . connect ( 'mongodb://127.0.0.1/test' )
8
+ mongoose . connect ( url )
6
9
. then ( ( ) => {
7
10
console . log ( '数据库连接成功' )
8
11
} )
Original file line number Diff line number Diff line change 5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
7
"test" : " echo \" Error: no test specified\" && exit 1" ,
8
- "dev" : " nodemon app.js"
8
+ "dev" : " set NODE_ENV=development && nodemon app.js" ,
9
+ "server" : " set NODE_ENV=production && nodemon app.js"
9
10
},
10
11
"keywords" : [],
11
12
"author" : " " ,
You can’t perform that action at this time.
0 commit comments