Curveball had a Context interface and BaseContext class. The idea was that it might be possible for users to create alternative Context classes.
In practice this has never happened, and is probably not that useful. The idea of using interfaces for everything is also something that I blindly applied before fully getting my bearings in Typescript.
The way things work with Curveball is that subclassing the Context is not the primary way to extend it, we monkey patch it because sublassing is not practical (for different reasons, lemme know if you want to know more).
There's some drawbacks to the interface. Patching the Context by other middlewares such as the router, session, oauth2 middleware and others is a really useful feature and lets them add new properties like ctx.session. To do that these packages all need to extend the interfaces twice and it's annoying. See for example this example from the router package:
Curveball had a Context interface and BaseContext class. The idea was that it might be possible for users to create alternative Context classes.
In practice this has never happened, and is probably not that useful. The idea of using interfaces for everything is also something that I blindly applied before fully getting my bearings in Typescript.
The way things work with Curveball is that subclassing the Context is not the primary way to extend it, we monkey patch it because sublassing is not practical (for different reasons, lemme know if you want to know more).
There's some drawbacks to the interface. Patching the Context by other middlewares such as the router, session, oauth2 middleware and others is a really useful feature and lets them add new properties like
ctx.session
. To do that these packages all need to extend the interfaces twice and it's annoying. See for example this example from the router package:This is a breaking change so this will be part of Curveball 0.18.