|
|
|
|
|
by yasserf
531 days ago
|
|
I feel that with typescript you can sort of build an SDK by creating a thin wrapper around fetch and have it consume the API types as a generic. This way you still have the benefits of type safety without the bloat of creating an actual SDK. SDKs tend to be useful when they hold state / don’t just proxy to a rest call, but I don’t see why we need wrapper libraries. They also hide away the complexity of knowing how the rest api is meant to consume data (query / params / body / encoding). So the assumption is the rest API itself makes sense. I took this approach with a backend typescript framework called vramework.dev which can generate openapi specs as well as the thin fetch wrapper, and feel like for my projects satisfies my needs. |
|