Created
October 27, 2018 08:56
-
-
Save paprikka/7b5a4fa03f1e79fd6a19d02d3a90145f to your computer and use it in GitHub Desktop.
Hapi route example
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 Events from '../events'; | |
const route = { | |
handler: ({params: {props}}, reply) => { | |
let parsedData; | |
try { | |
parsedData = JSON.parse(decodeURIComponent(props)); | |
} catch (err) { | |
console.log(err); | |
} | |
Events.save(parsedData); | |
reply({ | |
parsedData | |
}); | |
}, | |
description: 'Log event', | |
notes: '200 on success, no response body', | |
tags: ['api', 'log'], | |
validate: { | |
params: { | |
props: Joi.any().required().description('optional value') | |
} | |
} | |
}; | |
export default route; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment