const express = require('express');
const cors = require('cors');
const path = require('path');
const app = express();
// CORS 설정 - 모든 도메인 허용
app.use(cors({
origin: true,
credentials: true
}));
// JSON 파싱
app.use(express.json({ limit: '10mb' }));
app.use(express.urlencoded({ extended: true, limit: '10mb' }));
// 정적 파일 서빙
app.use(express.static(path.join(__dirname, '..')));
// 헬스 체크
app.get('/health', (req, res) => {
res.json({
success: true,
message: 'Jaryo File Manager is running',
timestamp: new Date().toISOString(),
environment: process.env.NODE_ENV || 'development'
});
});
// 루트 경로
app.get('/', (req, res) => {
res.send(`
Jaryo File Manager
🚀 Jaryo File Manager
✅ 배포 성공!
Vercel에서 성공적으로 배포되었습니다.
배포 시간: ${new Date().toLocaleString('ko-KR')}
📁 주요 기능
- 파일 업로드 및 관리
- 카테고리별 분류
- 파일 검색 및 다운로드
- 관리자 기능
`);
});
// API 라우트들
app.get('/api/files', (req, res) => {
res.json({
success: true,
data: [],
message: '파일 목록 API (데모 모드)'
});
});
app.get('/api/categories', (req, res) => {
res.json({
success: true,
data: [
{ id: 1, name: '문서', description: '문서 파일' },
{ id: 2, name: '이미지', description: '이미지 파일' },
{ id: 3, name: '기타', description: '기타 파일' }
],
message: '카테고리 목록'
});
});
// 404 핸들러
app.use((req, res) => {
res.status(404).json({
success: false,
error: '요청한 리소스를 찾을 수 없습니다.',
path: req.path
});
});
module.exports = app;