diff --git a/source/calendar/tec.js b/source/calendar/tec.js new file mode 100644 index 00000000..ad0ed160 --- /dev/null +++ b/source/calendar/tec.js @@ -0,0 +1,6 @@ +import {get} from '../ccc-lib/http.js' + +export async function theEventsCalendar(calendarUrl) { + let body = await get(calendarUrl).json() + return body.events +} diff --git a/source/ccci-stolaf-college/v1/calendar.js b/source/ccci-stolaf-college/v1/calendar.js index 8dddac52..575245d2 100644 --- a/source/ccci-stolaf-college/v1/calendar.js +++ b/source/ccci-stolaf-college/v1/calendar.js @@ -1,10 +1,12 @@ import {googleCalendar} from '../../calendar/google.js' import {ical} from '../../calendar/ical.js' +import {theEventsCalendar} from '../../calendar/tec.js' import {ONE_MINUTE} from '../../ccc-lib/constants.js' import mem from 'memoize' export const getGoogleCalendar = mem(googleCalendar, {maxAge: ONE_MINUTE}) export const getInternetCalendar = mem(ical, {maxAge: ONE_MINUTE}) +export const getTheEventsCalendar = mem(theEventsCalendar, {maxAge: ONE_MINUTE}) export async function google(ctx) { ctx.cacheControl(ONE_MINUTE) @@ -27,6 +29,14 @@ export async function stolaf(ctx) { ctx.body = await getGoogleCalendar(id) } +export async function eventsCalendar(ctx) { + ctx.cacheControl(ONE_MINUTE) + + let calendarUrl = + 'https://wp.stolaf.edu/calendar/wp-json/tribe/events/v1/events' + ctx.body = await getTheEventsCalendar(calendarUrl) +} + export async function oleville(ctx) { ctx.cacheControl(ONE_MINUTE) diff --git a/source/ccci-stolaf-college/v1/index.js b/source/ccci-stolaf-college/v1/index.js index 98c775ec..29274cc3 100644 --- a/source/ccci-stolaf-college/v1/index.js +++ b/source/ccci-stolaf-college/v1/index.js @@ -59,6 +59,7 @@ api.get('/food/named/menu/schulze', menus.schulzeMenu) api.get('/calendar/google', calendar.google) api.get('/calendar/ics', calendar.ics) api.get('/calendar/named/stolaf', calendar.stolaf) +api.get('/calendar/named/stolaf-tec', calendar.eventsCalendar) api.get('/calendar/named/oleville', calendar.oleville) api.get('/calendar/named/northfield', calendar.northfield) api.get('/calendar/named/krlx-schedule', calendar.krlx)