Not Implemented and Not Allowed error response docs example w/ Hapi Boom doesn't work
See original GitHub issuenode.js version:
❯ node -v
v14.17.3
npm/yarn and version:
❯ npm -v
6.14.13
@koa/router
version: 10.1.0
koa
version: 2.13.1
Code sample:
Borrowed from https://github.com/koajs/router/blob/master/API.md#routerallowedmethodsoptions--function
const Koa = require('koa');
const Router = require('@koa/router');
const Boom = require('boom');
const app = new Koa();
const router = new Router();
router.get('/ping', async ctx => {
ctx.body = 'PONG!'
})
app.use(router.routes());
app.use(router.allowedMethods({
throw: true,
notImplemented: () => new Boom.notImplemented(),
methodNotAllowed: () => new Boom.methodNotAllowed()
}));
app.listen(8080)
Expected Behavior:
Should “just work” and give me 501 NOT IMPLEMENTED
when I call a route that doesn’t an HTTP method implemented
Actual Behavior:
500 Internal Error
Console output:
TypeError: Boom.methodNotAllowed is not a constructor
Additional steps, HTTP request details, or to reproduce the behavior or a test case:
curl -X POST -I http://localhost:8080/ping
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Can boom package be used only for server-side development?
Hello, First of all, guys, thanks a lot for your project! It really simplifies our backend tasks a lot! ) When we perform...
Read more >Hapi does not return data attribute from Boom error
Answer There is a reason the values passed back in the response payloads are pretty locked down. It's mostly for security and to...
Read more >boom v10.0.0 - hapi.dev
boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object which includes the following properties:....
Read more >There's No Reason to Write OpenAPI By Hand
An OpenAPI annotation framework provides a bunch of keywords that help the API developer describe the interface of the HTTP request and response...
Read more >hapi — How to Fix “handler method did not return a value, a ...
The error message means that you returned undefined or null from your route handler. Hapi v17 expects you to return either a value,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks again!
just reference it in the commit message and stuff