vagusX / koa-proxies

a koa@2.x+ proxy middleware
https://vagusx.github.io/koa-proxies/
MIT License
161 stars 43 forks source link

feat(typescript): improve TS definitions for better context support #76

Closed rilopez closed 8 months ago

rilopez commented 8 months ago

This pull request introduces improvements to the TypeScript type definitions. The primary goal of these changes is to enhance the support for Koa context typing, making the type definitions more flexible and robust for various usage scenarios.

Key Changes

  1. Generic Type Parameters: Added generic type parameters StateT, ContextT, and ResponseBodyT to KoaProxies function. This allows users to specify custom state, context, and response body types, aligning more closely with Koa's native typing system.
  2. Updated IBaseKoaProxiesOptions: Modified the IBaseKoaProxiesOptions interface to accept a generic ContextT type. This change provides better integration with custom Koa contexts.
  3. Enhanced Type Safety: By introducing these generic parameters, the type definitions now offer improved type safety and developer experience in TypeScript environments.

Motivation

The motivation for these changes comes from encountering limitations with the current TypeScript definitions when working with custom Koa contexts. The lack of generic type support made it challenging to integrate koa-proxies seamlessly into TypeScript projects that utilize custom context types.

Impact

Looking forward to feedback and suggestions!

rilopez commented 8 months ago

closing it to create the pullrequest from my team account