- YouTube 일정 봇 서비스 추가 (youtube-bot.js, youtube-scheduler.js) - 공개 일정 API 라우터 추가 (schedules.js) - 관리자 일정 봇 관리 페이지 추가 (AdminScheduleBots.jsx) - 백엔드 의존성 업데이트
45 lines
1.4 KiB
JavaScript
45 lines
1.4 KiB
JavaScript
import express from "express";
|
|
import path from "path";
|
|
import { fileURLToPath } from "url";
|
|
import membersRouter from "./routes/members.js";
|
|
import albumsRouter from "./routes/albums.js";
|
|
import statsRouter from "./routes/stats.js";
|
|
import adminRouter from "./routes/admin.js";
|
|
import schedulesRouter from "./routes/schedules.js";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
const app = express();
|
|
const PORT = process.env.PORT || 80;
|
|
|
|
// JSON 파싱
|
|
app.use(express.json());
|
|
|
|
// 정적 파일 서빙 (프론트엔드 빌드 결과물)
|
|
app.use(express.static(path.join(__dirname, "dist")));
|
|
|
|
// API 라우트
|
|
app.get("/api/health", (req, res) => {
|
|
res.json({ status: "ok", timestamp: new Date().toISOString() });
|
|
});
|
|
|
|
app.use("/api/members", membersRouter);
|
|
app.use("/api/albums", albumsRouter);
|
|
app.use("/api/stats", statsRouter);
|
|
app.use("/api/admin", adminRouter);
|
|
app.use("/api/schedules", schedulesRouter);
|
|
app.use("/api/schedule-categories", (req, res, next) => {
|
|
// /api/schedule-categories -> /api/schedules/categories로 리다이렉트
|
|
req.url = "/categories";
|
|
schedulesRouter(req, res, next);
|
|
});
|
|
|
|
// SPA 폴백 - 모든 요청을 index.html로
|
|
app.get("*", (req, res) => {
|
|
res.sendFile(path.join(__dirname, "dist", "index.html"));
|
|
});
|
|
|
|
app.listen(PORT, () => {
|
|
console.log(`🌸 fromis_9 서버가 포트 ${PORT}에서 실행 중입니다`);
|
|
});
|