feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
25
api.hyungi.net/controllers/pingController.js
Normal file
25
api.hyungi.net/controllers/pingController.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// controllers/pingController.js
|
||||
const { getDb } = require('../dbPool');
|
||||
const pingModel = require('../models/pingModel');
|
||||
|
||||
exports.ping = async (req, res) => {
|
||||
const data = pingModel.ping();
|
||||
try {
|
||||
// DB 연결 테스트
|
||||
const db = await getDb();
|
||||
await db.query('SELECT 1');
|
||||
return res.json({
|
||||
success: true,
|
||||
...data,
|
||||
db: 'ok'
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('[PING ERROR]', err);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: 'db error',
|
||||
timestamp: data.timestamp,
|
||||
error: err.message
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user