Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

silent failure when setting an empty string as the path in e.g. @Get() and @Post() decorators #41

Open
Thesephi opened this issue Dec 11, 2024 · 0 comments

Comments

@Thesephi
Copy link
Owner

Version: latest (0.12.2 atm)
Reproduction:

@Controller()
export class MyController {
  @Post("")
  @ControllerMethodArgs("body")
  listen(
    body: any
  ) {
    console.log("received", body);
    return "to be implemented";
  }
}

Expectation: the snippet above results in the index route (/) being handled
Actual:

* Connected to localhost (127.0.0.1) port 1993
> POST / HTTP/1.1
> Host: localhost:1993
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 13
>
< HTTP/1.1 404 Not Found
< content-length: 0
< date: Wed, 11 Dec 2024 01:52:13 GMT
<
* Connection #0 to host localhost left intact

Notes: even this seems to be an unconventional (undocumented) usage (ie setting an empty string "" as the path, instead of a slash /), it's better to choose between:

  1. throwing an error or visible warning
  2. just defaulting empty string to / (and treating it as the index route by default)

Either approach above is better than silently failing / not handling the route like currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant