[] DB 연결 테스트 코드 작성
Some checks failed
Stein_Back/pipeline/head This commit looks good
Back/pipeline/head There was a failure building this commit

This commit is contained in:
김선규 2024-08-09 16:31:33 +09:00
parent 6a7fa38b96
commit cefd78f422

View File

@ -1,25 +1,19 @@
import express, { query } from 'express';
import { createDatabaseConnection } from '../db/database.js'; // db 연결 파일
import { HandlePush } from './push.js';
import { rtDBConfig } from '../private/config.js';
// const cmcd = "/JJ";
// const db = "/JJ/db";
const app = express();
app.use(express.json());
import { rtDBConfig } from '../private/config.js'; // 프라이빗 파일 연결
const router = express.Router();
// DB 연결 테스트
app.get(`${db}/test`, async (req, res) => {
router.get(`/test`, async (req, res) => {
try {
const connection = await createDatabaseConnection(dbConfig);
const connection = await createDatabaseConnection(rtDBConfig);
const [rows] = await connection.query('SELECT * FROM version');
await connection.end();
res.json({ result: rows[0].solution });
res.json(rows);
} catch (err) {
res.status(500).json({ error: err.message });
}
});
export default app;
export default router;