diff --git a/.gitignore b/.gitignore index a206f04..260aa50 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ .history .env +.env.* +!.env.example +.vite .windsurfrules config.js backend/node_modules/* diff --git a/backend/app.js b/backend/app.js index 0593538..a947843 100644 --- a/backend/app.js +++ b/backend/app.js @@ -80,7 +80,7 @@ app.get('/', (req, res) => { // 서버 시작 const PORT = process.env.PORT || 3030; server.listen(PORT, () => { - console.log(`서버가 포트 ${PORT}에서 실행 중입니다.`); + console.log(`서버가 ${process.env.NODE_ENV} 환경으로 포트 ${PORT}에서 실행 중입니다.`); }); module.exports = app; diff --git a/backend/config/database.js b/backend/config/database.js index 12aa3fa..9bbc731 100644 --- a/backend/config/database.js +++ b/backend/config/database.js @@ -1,5 +1,14 @@ const { Sequelize } = require('sequelize'); -require('dotenv').config(); +const path = require('path'); + +// 환경 변수 설정 +const env = process.env.NODE_ENV || 'development'; +const envPath = path.resolve(process.cwd(), `.env.${env}`); + +// 환경별 .env 파일 로드 +require('dotenv').config({ + path: envPath +}); const sequelize = new Sequelize( process.env.DB_NAME, @@ -9,7 +18,7 @@ const sequelize = new Sequelize( host: process.env.DB_HOST, port: process.env.DB_PORT, dialect: 'mysql', - logging: true, // 개발 중에는 true로 설정하여 SQL 쿼리 로그 확인 가능 + logging: process.env.NODE_ENV === 'development' ? console.log : false, // 개발 환경에서만 로깅 활성화 pool: { max: 5, min: 0, diff --git a/backend/controllers/eventController.js b/backend/controllers/eventController.js index e2ae7e2..9ebd836 100644 --- a/backend/controllers/eventController.js +++ b/backend/controllers/eventController.js @@ -32,6 +32,7 @@ exports.getAllEvents = async (req, res) => { where: { status: { [Op.ne]: '취소' } }, + required: false, include: [{ model: Member, attributes: ['id', 'name', 'memberType', 'gender'] @@ -83,6 +84,7 @@ exports.getEventById = async (req, res) => { where: { status: { [Op.ne]: '취소' } }, + required: false, include: [{ model: Member, attributes: ['id', 'name'] @@ -145,7 +147,7 @@ exports.createEvent = async (req, res) => { clubId, title, description, - startDate: new Date(startDate), + startDate: startDate ? startDate : null, endDate: endDateVal, location, maxParticipants: maxParticipants || 0, @@ -220,8 +222,8 @@ exports.updateEvent = async (req, res) => { const updateData = { title, description, - startDate: startDate ? new Date(startDate) : event.startDate, - endDate: endDate ? new Date(endDate) : null, + startDate: startDate ? startDate : event.startDate, + endDate: endDate || null, location, maxParticipants: maxParticipants || event.maxParticipants, eventType: eventType || event.eventType, @@ -246,11 +248,16 @@ exports.updateEvent = async (req, res) => { attributes: ['id', 'status'], where: { status: { [Op.ne]: '취소' } - } + }, + required: false } ] }); + if (!updatedEvent) { + return res.status(404).json({ message: '이벤트를 찾을 수 없습니다.' }); + } + res.json({ message: '이벤트가 수정되었습니다.', event: { diff --git a/backend/models/index.js b/backend/models/index.js index a853b71..6246b82 100644 --- a/backend/models/index.js +++ b/backend/models/index.js @@ -1,4 +1,5 @@ const { sequelize } = require('../config/database'); +const { Op } = require('sequelize'); const User = require('./User'); const Club = require('./Club'); const Event = require('./Event'); @@ -160,7 +161,7 @@ const createSampleData = async () => { await Club.destroy({ where: {} }); await Feature.destroy({ where: {} }); await SubscriptionPlan.destroy({ where: {} }); - await User.destroy({ where: {} }); + await User.destroy({ where: { email: { [Op.ne]: process.env.ADMIN_EMAIL } } }); console.log('기존 데이터가 모두 삭제되었습니다.'); // 2. 샘플 사용자 데이터 생성 diff --git a/backend/package.json b/backend/package.json index f9a589e..9773c68 100644 --- a/backend/package.json +++ b/backend/package.json @@ -3,7 +3,10 @@ "version": "1.0.0", "main": "index.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "start": "NODE_ENV=production node app.js", + "cleanup": "lsof -ti:3030 | xargs kill -9 || true", + "dev": "npm run cleanup && NODE_ENV=development nodemon app.js", + "test": "NODE_ENV=test jest" }, "keywords": [], "author": "", diff --git a/backend/routes/adminRoutes.js b/backend/routes/adminRoutes.js index e9aa25b..9306ef9 100644 --- a/backend/routes/adminRoutes.js +++ b/backend/routes/adminRoutes.js @@ -1,6 +1,7 @@ const express = require('express'); const router = express.Router(); const { Club, Member, User, Feature, ClubFeature, ActivityLog, SubscriptionPlan, Meeting, MeetingParticipant, ClubSubscription } = require('../models'); +const clubController = require('../controllers/clubController'); const { sequelize } = require('../models/index'); const { Op } = require('sequelize'); const { authenticateJWT, authorizeRoles } = require('../middleware/authMiddleware'); @@ -1294,6 +1295,9 @@ router.get('/clubs/:id', async (req, res) => { } }); +// 새 클럽 생성 +router.post('/clubs', authenticateJWT, clubController.createClub); + // 클럽 수정 router.put('/clubs/:id', async (req, res) => { try { diff --git a/frontend/package.json b/frontend/package.json index baae4d2..7516681 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,7 +4,8 @@ "private": true, "type": "module", "scripts": { - "dev": "vite --host 0.0.0.0 --port 5173", + "cleanup": "pkill -f esbuild || true", + "dev": "npm run cleanup && vite --host 0.0.0.0 --port 5173", "build": "vite build", "preview": "vite preview" }, diff --git a/frontend/src/components/event/EventDialog.vue b/frontend/src/components/event/EventDialog.vue index dbd6dca..5af1332 100644 --- a/frontend/src/components/event/EventDialog.vue +++ b/frontend/src/components/event/EventDialog.vue @@ -99,6 +99,7 @@