버그 수정
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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: {
|
||||
|
||||
@@ -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. 샘플 사용자 데이터 생성
|
||||
|
||||
@@ -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": "",
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user