Skip to content
Snippets Groups Projects
Commit 360e88be authored by 조대희's avatar 조대희
Browse files

feat: 스케줄 생성 컨트롤러 (#6)

parent 90a1dec6
No related branches found
No related tags found
2 merge requests!31Develop,!7[#6] Schedule 컨트롤러, 라우터, 로직 개발
const ScheduleService = require('../services/scheduleService');
class scheduleController {
/**
* 스케줄 생성
* POST /api/schedules
* 해당 사용자 id는 auth 미들웨어에서 설정된 사용자 정보 이용
* req.user = User 모델의 인스턴스
*/
async createSchedule(req, res) {
try {
const userId = req.user.id;
const { title, start_time, end_time, is_fixed } = req.body;
const schedule = await ScheduleService.createSchedule({
userId,
title,
start_time,
end_time,
is_fixed
});
return res.status(201).json({
success: true,
data: {
schedule
}
});
} catch (error) {
return res.status(400).json({
success: false,
error: {
message: error.message,
code: 'SCHEDULE_CREATE_ERROR'
}
});
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment