Skip to content

Instantly share code, notes, and snippets.

@optii
Created March 19, 2018 11:24
Show Gist options
  • Save optii/c1c3146ff6c78eb278a41d1eb17db446 to your computer and use it in GitHub Desktop.
Save optii/c1c3146ff6c78eb278a41d1eb17db446 to your computer and use it in GitHub Desktop.
response
const Hapi = require('hapi');
const Joi = require('joi');
const server = Hapi.server({ port : 4000 });
server.route({
method : 'GET',
path : '/',
handler : (request, h) => {
if (request.query.redirect) {
return h.redirect('http://google.com');
}
return {
a : 12
};
},
options : {
response : {
schema : Joi.object({
a: Joi.number().integer()
}),
sample : 100,
status : {
302 : true
}
}
}
});
const start = async () => {
await server.start();
console.log('Started');
};
start();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment