Skip to content

Commit

Permalink
adds calendar to event in cannon (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreromao authored Apr 10, 2024
1 parent 3b3d618 commit 7653900
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions server/resources/deck.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ function transformEvent(event, options) {
public: options?.public || true,
date: event.begin,
duration: new Date(new Date(event.end) - new Date(event.begin)),
calendarUrl: event.calendarUrl,
}
}

Expand Down
16 changes: 16 additions & 0 deletions server/routes/deck/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,19 @@ exports.getSpeaker = {
}
}
}

exports.getCalendarUrl = {
options: {
tags: ['api', 'calendar'],
description: 'Get the calendar url for the current edition'
},
handler: async (request, h) => {
try {
const edition = await request.server.methods.deck.getLatestEdition()
return h.response(edition.calendarUrl)
} catch(err) {
log.error({ error: err })
throw Boom.boomify(err)
}
}
}
7 changes: 7 additions & 0 deletions server/routes/deck/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,11 @@ server.route({
path: '/speaker/{speakerId}',
options: handlers.getSpeaker.options,
handler: handlers.getSpeaker.handler
})

server.route({
method: 'GET',
path: '/calendar',
options: handlers.getCalendarUrl.options,
handler: handlers.getCalendarUrl.handler
})
3 changes: 2 additions & 1 deletion server/views/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = function render (content) {
duration: model.duration,
begin: model.begin,
end: model.end,
isOcurring: model.isOcurring
isOcurring: model.isOcurring,
calendarUrl: model.calendarUrl,
}
}

0 comments on commit 7653900

Please sign in to comment.