- 백엔드: /api/albums 라우트 추가 (routes/albums.js) - 앨범별 트랙 정보 포함 조회 - 프론트엔드: Discography 페이지 API 연동 - 앨범 타입별 통계 동적 계산 - 타이틀곡 자동 표시
28 lines
730 B
JavaScript
28 lines
730 B
JavaScript
import express from "express";
|
|
import pool from "../lib/db.js";
|
|
|
|
const router = express.Router();
|
|
|
|
// 통계 조회 (멤버 수, 앨범 수)
|
|
router.get("/", async (req, res) => {
|
|
try {
|
|
const [memberCount] = await pool.query(
|
|
"SELECT COUNT(*) as count FROM members"
|
|
);
|
|
const [albumCount] = await pool.query(
|
|
"SELECT COUNT(*) as count FROM albums"
|
|
);
|
|
|
|
res.json({
|
|
memberCount: memberCount[0].count,
|
|
albumCount: albumCount[0].count,
|
|
debutYear: 2018,
|
|
fandomName: "flover",
|
|
});
|
|
} catch (error) {
|
|
console.error("통계 조회 오류:", error);
|
|
res.status(500).json({ error: "통계 정보를 가져오는데 실패했습니다." });
|
|
}
|
|
});
|
|
|
|
export default router;
|