Created
February 8, 2019 15:38
-
-
Save juliantellez/87723a9059e74c91bfb378d080311f28 to your computer and use it in GitHub Desktop.
using Lambcycle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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