nestjs-paginate icon indicating copy to clipboard operation
nestjs-paginate copied to clipboard

Factor out `Paginate` function (for testing)

Open Helveg opened this issue 1 year ago • 0 comments

Currently the Paginate decorator does (_data: unknown, ctx: ExecutionContext) => PaginateQuery, but is encapsulated as a parameter decorator factory. However, when I'm unit testing, I haven't figured out how to leverage NestJS to resolve these parameters for me, in lieu of that, it would be nice if I could call something like getPaginateQueryFromContext directly :)

We just have to:

export const getPaginateQueryFromContext = (ctx: ExecutionContext) => {...}
export const Paginate = createParamDecorator((_data: unknown, ctx: ExecutionContext) => getPaginateQueryFromContext(ctx))

I will PR this when I have time for it in a few weeks (together with finishing up the JSON:API stuff!)

Helveg avatar Dec 03 '23 16:12 Helveg