Skip to content

Instantly share code, notes, and snippets.

@paprikka paprikka/route.js
Created Oct 27, 2018

Embed
What would you like to do?
Hapi route example
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
You can’t perform that action at this time.