-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {defineSchema} from '../../libs/schema'; | ||
import {defineRoute} from '../../libs/route'; | ||
import EventService from '../../../service/EventService'; | ||
import {EventResponseScheme} from '../../../entity/schemes'; | ||
|
||
const schema = defineSchema({ | ||
summary: '내가 쓴 행사를 다 가져옵니다.', | ||
description: '행사 id 역순으로 가져옵니다.', | ||
|
||
response: [EventResponseScheme] | ||
}); | ||
|
||
export default defineRoute('get', '/myevents', schema, async (req, res) => { | ||
const userId = req.requireUserId(); | ||
const eventInformation = await EventService.getMyEvents(userId); | ||
return res.json(await Promise.all(eventInformation.map(e => e.toResponse(userId)))) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
널 체크 아주 좋아요!
근데 findOneOrFail로 가져오면 null인 경우는 없답니다(없으면 예외 발생하고 404 응답이 나가요)
사용자가 없을때 예외를 던지지 않고 조용히 지나가기를 원하신다면 findOneOrFail을 findOne으로 바꿔주시면 되구, 지금 이대로 두고 싶으시면 딱히 수정을 안해도 되어용(물론 if문은 의미가 없을거예용)