question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not Implemented and Not Allowed error response docs example w/ Hapi Boom doesn't work

See original GitHub issue

node.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:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
niftylettucecommented, Aug 22, 2021

Thanks again!

1reaction
niftylettucecommented, Aug 21, 2021

just reference it in the commit message and stuff

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found