You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using this package outside of nestjs in a pure expressjs application. it works well but there are some issues.
However, I recently discovered that this file in the project is the only thing that can't be applied in express because we can't use decorators outside of classes. If we can modify this file and split it into two functions, one exported as a general function, the other is what makes up a decorator from it, we can import the regular function, then wrap it as an express middleware and use it right in our projects.
Great point - might just build 2 packages from this repo. You are welcome to restructure the code 2 support both versions. I will take care of the release process.
Even in NestJS I've run into a use case for this. It requires a pretty nasty workaround at the moment to apply the inner function of the Paginate decorator:
// To assemble the PaginateQuery, we fish out `nestjs-paginate`'s paginate query// factory from the NestJS parameter decorator// First, we decorate our dec dummy with the Paginate decoratorconstdec=class{};Paginate()(dec,'fishy fishy',0);// And we declare the types of what we're going to fish outreturnObject.values<{factory: (_data: unknown,ctx: ExecutionContext)=>PaginateQuery;}>(// Then we fish out the route args metadata factory for what we just decorated.Reflect.getMetadata(ROUTE_ARGS_METADATA,dec.constructor,'fishy fishy',),// Then we use the fished out factory to produce the PaginateQuery from the// spoofed request context)[0].factory(null,reqCtx);
It'd be nicer if we split out a getPaginateQuery(req) function.
PS: I must have amnesia, I had appearantly already opened an issue here: #825
I am using this package outside of nestjs in a pure expressjs application. it works well but there are some issues.
However, I recently discovered that this file in the project is the only thing that can't be applied in express because we can't use decorators outside of classes. If we can modify this file and split it into two functions, one exported as a general function, the other is what makes up a decorator from it, we can import the regular function, then wrap it as an express middleware and use it right in our projects.
click here to view the file.
Let me know what are your opinions.
For example, I was able to get it to work by doing this
The text was updated successfully, but these errors were encountered: