serverless-local-dev-server
Version:
Develop Alexa-Skill and HTTP functions in Serverless without deploying to AWS
28 lines (25 loc) • 637 B
JavaScript
const mappings = {
'alexaSkill': require('./AlexaSkillEndpoint'),
'http': require('./HttpEndpoint')
}
module.exports = (func) => {
return func.config.events.map(event => {
switch (typeof event) {
case 'string':
return { type: event, config: {} }
case 'object':
let type = Object.keys(event)[0]
return { type: type, config: event[type] }
/* istanbul ignore next */
default:
return null
}
}).filter(_ =>
!!mappings[_.type]
).map(_ => {
let endpoint = new mappings[_.type](_.config, func)
endpoint.type = _.type
return endpoint
})
}