nestjsx / nest-router

Router Module For Nestjs Framework 🚦 🚀
MIT License
619 stars 36 forks source link

dynamic path intercepts static #168

Open SalischevArtem opened 2 years ago

SalischevArtem commented 2 years ago

Hello!

I have the issue which was discussed but can't apply the suggested resolving.

I have two DELETE like bellow :

@Delete('/agent/:id') async deleteInactiveAgentFromProfiles( @Param('id') id: string, ): Promise { return this.profilesService.deleteInactiveAgentFromProfilesById(id); }

@Delete(':id') async deleteProfile(@Param('id') id: string): Promise { return this.profilesService.deleteProfileById(id); }

My ids smt like this /^UPC-[0-9A-F]{19}-[0-9A-F]{1}$/

So regarding this issue in second DELETE I have to do smth like this @Delete('/:id(^UPC-[0-9A-F]{19}-[0-9A-F]{1}$)/') But it doesn’t work.

What I'm doing wrong?

Thank for helping.

shekohex commented 2 years ago

Could you try @Delete(/(^UPC-[0-9A-F]{19}-[0-9A-F]{1}$)/)?

SalischevArtem commented 2 years ago

Unfortunately, it doesn’t work. Argument of type 'RegExp' is not assignable to parameter of type 'string | string[]'.

meehol commented 2 years ago

Having same issue

shekohex commented 2 years ago

Interesting, one question is does you have the same issue with the built-in RounterModule in nestjs?

Also, maybe it should work like so @Delete('/:id(^UPC-[0-9A-F]{19}-[0-9A-F]{1}$)/')