From ba93dfe8329bd8a7019e7d550eda939eb1770287 Mon Sep 17 00:00:00 2001 From: Ahn YoungSeon Date: Sat, 18 Dec 2021 15:33:43 +0900 Subject: [PATCH] =?UTF-8?q?#29=20database=20config=20data=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/db.js | 9 +++++---- config/env.js | 7 +++++++ main.js | 23 +++++++++++------------ 3 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 config/env.js diff --git a/config/db.js b/config/db.js index 2b70603..d8a8003 100644 --- a/config/db.js +++ b/config/db.js @@ -1,10 +1,11 @@ var mysql = require('mysql'); +const env = require('./env'); const db = mysql.createConnection({ - host: 'localhost', - user: 'root', - password: 'qwerty123', - database: 'hialcohol', + host: env.host, + user: env.user, + password: env.password, + database: env.database, dateStrings: 'date' }); diff --git a/config/env.js b/config/env.js new file mode 100644 index 0000000..c966c89 --- /dev/null +++ b/config/env.js @@ -0,0 +1,7 @@ +module.exports = { + host: 'localhost', + user: 'root', + password: 'qwerty123', + database: 'hialcohol', + port: 3000 +}; \ No newline at end of file diff --git a/main.js b/main.js index 0f13549..fda3b24 100644 --- a/main.js +++ b/main.js @@ -1,24 +1,23 @@ const express = require('express'); const app = express(); -const port = 3000; const bodyParser = require('body-parser'); -const indexRouter = require('./routes/indexRouter.js') const session = require('express-session'); const MySQLStore = require('express-mysql-session')(session); +const passport = require('passport'); +const flash = require('connect-flash'); +const cookieParser = require('cookie-parser'); +const indexRouter = require('./routes/indexRouter.js') const oauthRouter = require('./routes/loginRouter.js'); const likeRouter = require('./routes/likeRouter'); const boardRouter = require('./routes/boardRouter.js') const search_listRouter = require('./routes/search_listRouter.js'); const mapRouter = require('./routes/mapRouter'); -const passport = require('passport'); -const flash = require('connect-flash'); - const passportConfig = require('./passport'); -const cookieParser = require('cookie-parser'); +const boardProcessRouter = require('./routes/boardProcessRouter.js'); +const env = require('./config/env.js'); -const boardProcessRouter = require('./routes/boardProcessRouter.js') -const db = require('./config/db.js') +const port = env.port; app.use(cookieParser('ras')); passportConfig(); @@ -31,11 +30,11 @@ app.use(session({ secure: false, saveUninitialized: true, store: new MySQLStore({ - host: "localhost", + host: env.host, port: 3306, - user: "root", - password: "qwerty123", - database: "hialcohol" + user: env.user, + password: env.password, + database: env.database }) })); app.use(passport.initialize());