({ request, user, match, session, isRunningLocally }: RequestHandlerParams)
| 9 | const titlePrefix = 'Calendars'; |
| 10 | |
| 11 | async function get({ request, user, match, session, isRunningLocally }: RequestHandlerParams): Promise<Response> { |
| 12 | const calendarConfig = await AppConfig.getCalendarConfig(); |
| 13 | |
| 14 | if (!calendarConfig.enableCalDavServer) { |
| 15 | throw new Error('CalDAV server is not enabled'); |
| 16 | } |
| 17 | |
| 18 | if (!(await AppConfig.isAppEnabled('calendar'))) { |
| 19 | throw new Error('Calendar app is not enabled'); |
| 20 | } |
| 21 | |
| 22 | const userCalendars = await CalendarModel.list(user!.id); |
| 23 | |
| 24 | const htmlContent = defaultHtmlContent({ userCalendars }); |
| 25 | |
| 26 | return basicLayoutResponse(htmlContent, { |
| 27 | currentPath: match.pathname.input, |
| 28 | titlePrefix, |
| 29 | match, |
| 30 | request, |
| 31 | user, |
| 32 | session, |
| 33 | isRunningLocally, |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | function defaultHtmlContent({ userCalendars }: { userCalendars: Calendar[] }) { |
| 38 | return html` |
nothing calls this directly
no test coverage detected