Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
RunKit + npm: @hapi/hapi
node v18.11.0
endpoint
share
tweet
require("@hapi/statehood"); // runkit bug? const { Server } = require("@hapi/hapi"); const Joi = require("joi"); const server = new Server({ routes: { validate: { failAction(request, h, err) { throw err; } } } }); server.validator(Joi); server.route({ method: 'GET', path: '/{id}', handler: ({ params }) => params.id, options: { validate: { params: Joi.object({ id: Joi.number() .positive() .messages({ "number.positive": "Id must be positive.", }) }) } } }) await server.inject('/-12')
Created from: https://npm.runkit.com/@hapi/hapi
Loading…
Clone and edit this document