Skip to content

Instantly share code, notes, and snippets.

@juliantellez
Created February 8, 2019 15:38
Show Gist options
  • Save juliantellez/87723a9059e74c91bfb378d080311f28 to your computer and use it in GitHub Desktop.
Save juliantellez/87723a9059e74c91bfb378d080311f28 to your computer and use it in GitHub Desktop.
using Lambcycle
import Joi from 'joi'
import lambcycle from 'lambcycle'
import joiPlugin from 'lambcycle/dist/plugin-joi'
import bodyParser from 'lambcycle/dist/plugin-body-parser'
import realTimeEventTracker from './bugFreeBizLogic'
const businessLogic = async(event, context) => {
const {error, data} = await realTimeEventTracker(event.data)
if(error) {
throw error
}
return data;
};
const schema = Joi.object().keys({
assetId: Joi.string().required(),
competition: Joi.string().required(),
sport: Joi.string(),
tournamentCalendar: Joi.date(),
}).required()
const handler = lambcycle(businessLogic)
.register([
bodyParser({type: 'json'}),
joiPlugin(schema)
])
export default handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment