loreanvictor / tyfon

typed functions over network
https://loreanvictor.github.io/tyfon
MIT License
37 stars 4 forks source link

add access to request context #13

Closed loreanvictor closed 3 years ago

loreanvictor commented 3 years ago

Why?

Without this TyFON-servers cannot handle webhooks from third-party services without using a custom server (which is not as convenient).

Cons

If function f() expects specific data in request context on the server-side, then calling it on the client-side should be injecting that specific data in the expected format. With proper pairing of injector (client) and extractor (server) side codes, this will be basically the custom types idea mentioned here.

I believe that not providing direct access to request context on client-side, alongside proper documentation, should keep this safe though.

Implementation Suggestion

via this argument:

export async function myThingy() {
  const hookData = this.req.body;
  ...
}