MCPcopy Index your code
hub / github.com/nodejs/nodejs.org / getCalendarEvents

Function getCalendarEvents

apps/site/next.calendar.mjs:15–40  ·  view source on GitHub ↗
(calendarId = '', maxResults = 20)

Source from the content-addressed store, hash-verified

13 * @returns {Promise<Array<import('./types').CalendarEvent>>}
14 */
15export const getCalendarEvents = async (calendarId = '', maxResults = 20) => {
16 const currentDate = new Date();
17 const nextWeekDate = new Date();
18
19 nextWeekDate.setDate(currentDate.getDate() + 7);
20
21 const calendarQueryParams = new URLSearchParams({
22 calendarId,
23 maxResults,
24 singleEvents: true,
25 timeZone: 'Etc/Utc',
26 key: SHARED_CALENDAR_KEY,
27 timeMax: nextWeekDate.toISOString(),
28 timeMin: currentDate.toISOString(),
29 });
30
31 const calendarQueryUrl = new URL(`${BASE_CALENDAR_URL}${calendarId}/events`);
32
33 calendarQueryParams.forEach((value, key) =>
34 calendarQueryUrl.searchParams.append(key, value)
35 );
36
37 return fetchWithRetry(calendarQueryUrl)
38 .then(response => response.json())
39 .then(calendar => calendar.items ?? []);
40};

Callers 1

UpcomingMeetingsFunction · 0.90

Calls 1

fetchWithRetryFunction · 0.90

Tested by

no test coverage detected