정승호

MongoDb 암호 숨김

1 -node_modules
...\ No newline at end of file ...\ No newline at end of file
1 +node_modules
2 +
3 +dev.js
......
1 +if(process.env.NODE_ENV=== 'production'){
2 + module.exports = require('./prod')
3 +} else{
4 + module.exports = require('./dev')
5 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module.exports = {
2 + mongoURI : process.env.MONGO_URI
3 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -6,19 +6,21 @@ const port = 5000 ...@@ -6,19 +6,21 @@ const port = 5000
6 6
7 const {User} = require('./models/Users'); 7 const {User} = require('./models/Users');
8 8
9 +const config = require('./config/dev')
10 +
9 app.use(bodyParser.urlencoded({extended : true})); 11 app.use(bodyParser.urlencoded({extended : true}));
10 app.use(bodyParser.json()); 12 app.use(bodyParser.json());
11 13
12 14
13 const mongoose = require('mongoose') 15 const mongoose = require('mongoose')
14 -mongoose.connect('mongodb+srv://platoon07:wony9795!!@2020oss-ysxss.mongodb.net/test?retryWrites=true&w=majority',{ 16 +mongoose.connect(config.mongoURI,{
15 useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex : true, useFindAndModify: false 17 useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex : true, useFindAndModify: false
16 }).then(() => console.log('MongoDb connected....')) 18 }).then(() => console.log('MongoDb connected....'))
17 .catch(err => console.log('Error')) 19 .catch(err => console.log('Error'))
18 20
19 21
20 22
21 -app.get('/', (req,res) => res.send('Hello world!!')) 23 +app.get('/', (req,res) => res.send('Hello world!! 오늘도 지식이 쌓였당!!'))
22 24
23 app.post('/register', (req, res) => { 25 app.post('/register', (req, res) => {
24 // 회원 가입시 필요한 정보들을 client에서 가져오면 26 // 회원 가입시 필요한 정보들을 client에서 가져오면
...@@ -34,7 +36,4 @@ app.post('/register', (req, res) => { ...@@ -34,7 +36,4 @@ app.post('/register', (req, res) => {
34 }) 36 })
35 37
36 38
37 -app.listen(port, () => console.log('example app listen on port ${port}!'))
38 -
39 -
40 -// mongodb+srv://platoon07:<password>@2020oss-ysxss.mongodb.net/test?retryWrites=true&w=majority
...\ No newline at end of file ...\ No newline at end of file
39 +app.listen(port, () => console.log('example app listen on port %s!', port))
......
This diff is collapsed. Click to expand it.
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
5 "main": "index.js", 5 "main": "index.js",
6 "scripts": { 6 "scripts": {
7 "start": "node index.js", 7 "start": "node index.js",
8 + "backend": "nodemon index.js",
8 "test": "echo \"Error: no test specified\" && exit 1" 9 "test": "echo \"Error: no test specified\" && exit 1"
9 }, 10 },
10 "repository": { 11 "repository": {
...@@ -16,7 +17,9 @@ ...@@ -16,7 +17,9 @@
16 "dependencies": { 17 "dependencies": {
17 "body-parser": "^1.19.0", 18 "body-parser": "^1.19.0",
18 "express": "^4.17.1", 19 "express": "^4.17.1",
19 - "mongoose": "^5.9.15", 20 + "mongoose": "^5.9.15"
21 + },
22 + "devDependencies": {
20 "nodemon": "^2.0.4" 23 "nodemon": "^2.0.4"
21 } 24 }
22 } 25 }
......