RunKit + npm: @hapi/hapi

node v18.11.0
endpointsharetweet
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…