Created
March 19, 2018 11:24
-
-
Save optii/c1c3146ff6c78eb278a41d1eb17db446 to your computer and use it in GitHub Desktop.
response
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
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