From 64aab40748b03babc36850f0cbf1cf2cf9509f5e Mon Sep 17 00:00:00 2001 From: "seonkyu.kim" Date: Tue, 20 Aug 2024 11:01:54 +0900 Subject: [PATCH] =?UTF-8?q?[=E2=9C=A8]=20=EB=94=94=EB=B9=84=20=EC=97=B0?= =?UTF-8?q?=EA=B2=B0=20=EB=B0=8F=20=EC=84=9C=EB=B2=84=20=EC=82=AC=EC=9A=A9?= =?UTF-8?q?=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/app.js | 43 +++++++++++++++++++++++++++++-------------- firebaseConfig.js | 2 +- index.js | 23 ++++++++++++++--------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/apps/app.js b/apps/app.js index 58dc4ef..e20d812 100644 --- a/apps/app.js +++ b/apps/app.js @@ -1,13 +1,28 @@ import express, { query } from 'express'; import { createDatabaseConnection } from '../db/database.js'; // db 연결 파일 -import { HandlePush } from './push.js'; import { dbConfig } from '../private/config.js'; +// import { HandlePush } from './push.js'; // const cmcd = "/JJ"; // const db = "/JJ/db"; +// const app = express(); +// app.use(express.json()); -const app = express(); -app.use(express.json()); + +const router = express.Router(); + +router.get(`/version`, async (req, res) => { + try { + const connection = await createDatabaseConnection(dbConfig); + const [rows] = await connection.query('SELECT * FROM version'); + await connection.end(); + res.json(rows); + } catch (err) { + res.status(500).json({ error: err.message }); + } +}); + +export default router; @@ -73,16 +88,16 @@ app.use(express.json()); // DB 연결 테스트 -app.get(`${db}/test`, async (req, res) => { - try { - const connection = await createDatabaseConnection(dbConfig); - const [rows] = await connection.query('SELECT 1 + 1 AS solution'); - await connection.end(); - res.json({ result: rows[0].solution }); - } catch (err) { - res.status(500).json({ error: err.message }); - } -}); +// app.get(`${db}/test`, async (req, res) => { +// try { +// const connection = await createDatabaseConnection(dbConfig); +// const [rows] = await connection.query('SELECT 1 + 1 AS solution'); +// await connection.end(); +// res.json({ result: rows[0].solution }); +// } catch (err) { +// res.status(500).json({ error: err.message }); +// } +// }); // /////////////////////////////////////////////////////////////// @@ -212,4 +227,4 @@ app.get(`${db}/test`, async (req, res) => { -export default app; \ No newline at end of file +// export default app; \ No newline at end of file diff --git a/firebaseConfig.js b/firebaseConfig.js index 2b68ac8..53d3a69 100644 --- a/firebaseConfig.js +++ b/firebaseConfig.js @@ -18,4 +18,4 @@ if (!getApps().some(app => app.name === 'jjungtableClientApp')) { jj_ClientApp = getApp('jjungtableClientApp'); } -export { admin, jj_ClientApp }; +export { admin, jj_ClientApp }; \ No newline at end of file diff --git a/index.js b/index.js index 9c06f48..d8c5f5d 100755 --- a/index.js +++ b/index.js @@ -9,6 +9,9 @@ import { fileURLToPath } from 'url'; import cookieParser from 'cookie-parser'; import cors from 'cors'; +import session from 'express-session'; // express-session 추가 +import routes from './apps/app.js'; // ./apps/app.js에서 라우트를 가져옴 + import { serverURL, serverPort } from './private/config.js'; const __filename = fileURLToPath(import.meta.url); @@ -19,9 +22,6 @@ console.log(process.cwd()); const app = express(); - - - app.use(cors()); app.use(bodyParser.json()); // For parsing application/json app.use(cookieParser()); // For parsing cookies @@ -45,7 +45,7 @@ const swaggerDefinition = { const options = { swaggerDefinition, - apis: ['./back/apps/push.js'], + apis: ['./back/apps/app.js'], }; const swaggerSpec = swaggerJSDoc(options); @@ -59,15 +59,20 @@ app.use((req, res, next) => { }); +app.use('/JJ', routes); + +app.listen(serverPort, () => { + console.log(`Server running`); +}); // Start the server //JJUNGTABLE 서버 연결 -const jjungTable_server = express(); -jjungTable_server.use(jjungTableApp); -jjungTable_server.listen(serverPort, () => { - console.log(`Server running`); -}); +// const jjungTable_server = express(); +// jjungTable_server.use(jjungTableApp); +// jjungTable_server.listen(serverPort, () => { +// console.log(`Server running`); +// }); // const sManagement_server = express(); // sManagement_server.use(sManagementApp);