[✨] DB 연결 테스트 코드 작성
This commit is contained in:
parent
6a7fa38b96
commit
cefd78f422
18
RT/app.js
18
RT/app.js
|
@ -1,25 +1,19 @@
|
||||||
import express, { query } from 'express';
|
import express, { query } from 'express';
|
||||||
import { createDatabaseConnection } from '../db/database.js'; // db 연결 파일
|
import { createDatabaseConnection } from '../db/database.js'; // db 연결 파일
|
||||||
import { HandlePush } from './push.js';
|
import { rtDBConfig } from '../private/config.js'; // 프라이빗 파일 연결
|
||||||
import { rtDBConfig } from '../private/config.js';
|
const router = express.Router();
|
||||||
|
|
||||||
// const cmcd = "/JJ";
|
|
||||||
// const db = "/JJ/db";
|
|
||||||
|
|
||||||
const app = express();
|
|
||||||
app.use(express.json());
|
|
||||||
|
|
||||||
|
|
||||||
// DB 연결 테스트
|
// DB 연결 테스트
|
||||||
app.get(`${db}/test`, async (req, res) => {
|
router.get(`/test`, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const connection = await createDatabaseConnection(dbConfig);
|
const connection = await createDatabaseConnection(rtDBConfig);
|
||||||
const [rows] = await connection.query('SELECT * FROM version');
|
const [rows] = await connection.query('SELECT * FROM version');
|
||||||
await connection.end();
|
await connection.end();
|
||||||
res.json({ result: rows[0].solution });
|
res.json(rows);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
res.status(500).json({ error: err.message });
|
res.status(500).json({ error: err.message });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default app;
|
export default router;
|
Loading…
Reference in New Issue
Block a user