Skip to content

Instantly share code, notes, and snippets.

@sergueyarellano
Created December 18, 2020 20:24
Show Gist options
  • Save sergueyarellano/99c823969cfb1a02d38250503e0e00de to your computer and use it in GitHub Desktop.
Save sergueyarellano/99c823969cfb1a02d38250503e0e00de to your computer and use it in GitHub Desktop.
module.exports.lambda = async (event, context) => {
// {Items: [{activities, day}, {activities, day}...]}
const reminders = event.detail
/*
* Use your logic to filter, discard the activities,
* we will end up with something like:
* [{activities, day}, {activities, day}, {activities, day}]
*/
const filteredReminders = filterActivitiesIn(reminders)
// Send the events to next step
const mappedEvents = filteredReminders.map((reminder) => {
return {
EventBusName: `main`,
Source: 'cron.filter',
DetailType: 'FILTERED REMINDERS',
Detail: JSON.stringify(reminder)
}
})
await eventBridge.putEvents({Entries: mappedEvents}).promise()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment