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

Allow Regex and Array in request mapping decorator #1343

Closed
abouroubi opened this issue Dec 5, 2018 · 6 comments
Closed

Allow Regex and Array in request mapping decorator #1343

abouroubi opened this issue Dec 5, 2018 · 6 comments

Comments

@abouroubi
Copy link

I'm submitting a...


[ ] Regression 
[ ] Bug report
[X ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When we decorate a controller function with the Post, Get, ... decorators, the param must be a string, but as the documentation of Express JS (https://expressjs.com/en/4x/api.html#path-examples) we can use Regex or array of strings, to match with multiple paths.

Is it possible to change it to allow this two types ?

Expected behavior

The possibility to use regex and arrays as params of a request mapping decorator.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Adding aliases for a route, for example for backward compatibility.

Environment

Nest version: 5.4.1

For Tooling issues:

  • Node version: XX
  • Platform:

Others:

@abouroubi
Copy link
Author

I checked the fastify documentation, and it seems like they don't support the array version out of the box, so if we want to support this in NestJS, we will need to find a workaround for providers other than express.

@elyesbenabdelkader
Copy link
Contributor

Also I think fastify, unlike express, does not support RegExp objects.

@marcus-sa
Copy link

marcus-sa commented Dec 18, 2018

Each server adapter should just validate whether or not regex etc is a valid option to use.

elyesbenabdelkader pushed a commit to elyesbenabdelkader/nest that referenced this issue Dec 19, 2018
This feature was requested in the issue nestjs#1343. When routing, besides using a single string, you can
now use an array of strings in the Post, Get, ... decorators.
elyesbenabdelkader pushed a commit to elyesbenabdelkader/nest that referenced this issue Jan 5, 2019
This feature was requested in the issue nestjs#1343. When routing, besides using a single string, you can
now use an array of strings in the Post, Get, ... decorators.
@kamilmysliwiec
Copy link
Member

PR merged and published as 5.7.0

@JohannesHoppe
Copy link

I would argue that this issue is only half done. Yes, now you can use an array of strings, but the OP also asked for a regex.

That would be very important for me so that we can migrate from an existing express.js solution.

@lock
Copy link

lock bot commented Sep 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants