[✨] 디비 연결 및 서버 사용 설정
This commit is contained in:
parent
3d3f6f2779
commit
64aab40748
43
apps/app.js
43
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;
|
||||
// export default app;
|
|
@ -18,4 +18,4 @@ if (!getApps().some(app => app.name === 'jjungtableClientApp')) {
|
|||
jj_ClientApp = getApp('jjungtableClientApp');
|
||||
}
|
||||
|
||||
export { admin, jj_ClientApp };
|
||||
export { admin, jj_ClientApp };
|
23
index.js
23
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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user