0.4.119 • Published 2 years ago

@http4t/bidi v0.4.119

Weekly downloads
54
License
Apache-2.0
Repository
-
Last release
2 years ago

Bi-directional routing

NB: This is nowhere near production ready at time of writing.

Goals

HTTP routes that can be shared by clients and server

I should be able to define a route at GET /widgets/{id} and use that route to both:

  • Match a request on the server side, then route it to a handler function
  • Create a request on the client side and pass it to an HttpHandler

By sharing the routes between client and server I avoid bugs with my client sending the wrong shaped requests to my server.

Fully type-safe contracts for both client and server

If I have a route GET /widgets/{widgetId} that returns a json-serialised response body containing a Widget, I want to be able to give my server a handler function that knows nothing about http, like:

(args: {widgetId: string}) => Promise<Widget>

...and have the server destructure the request into that shape and then serialise the function result into an HttpResponse.

On the client side, I want to be able to generate a function with the same signature that takes care of serialising to an HttpRequest, sending to an HttpHandler, then deserialising from HttpResponse.

Examples

See client.test.ts for an example of a complete round trip from client to server and back.

0.4.119

2 years ago

0.4.109

2 years ago

0.4.110

2 years ago

0.3.63

3 years ago

0.3.62

4 years ago

0.2.61

4 years ago

0.1.49

5 years ago

0.1.45

5 years ago

0.1.46

5 years ago

0.1.47

5 years ago

0.1.48

5 years ago

0.1.38

5 years ago

0.1.30

5 years ago

0.1.31

5 years ago

0.1.32

5 years ago

0.1.33

5 years ago

0.1.34

5 years ago

0.1.35

5 years ago

0.1.37

5 years ago

0.1.29

5 years ago

0.1.28

5 years ago

0.1.27

5 years ago

0.1.21

5 years ago

0.1.22

5 years ago

0.1.23

5 years ago

0.1.24

5 years ago

0.1.19

5 years ago

0.0.158

5 years ago

0.0.156

5 years ago

0.0.155

5 years ago

0.0.153

5 years ago

0.0.152

5 years ago

0.0.151

5 years ago

0.0.150

5 years ago

0.0.149

5 years ago

0.0.148

5 years ago

0.0.145

5 years ago

0.0.144

5 years ago

0.0.143

5 years ago

0.0.142

5 years ago

0.0.141

5 years ago

0.0.140

5 years ago

0.0.139

5 years ago

0.0.128

5 years ago

0.0.138

5 years ago

0.0.137

5 years ago

0.0.129

5 years ago

0.0.131

5 years ago

0.0.130

5 years ago

0.0.123

5 years ago

0.0.122

5 years ago

0.0.121

5 years ago

0.0.119

5 years ago

0.0.117

5 years ago

0.0.118

5 years ago

0.0.114

5 years ago

0.0.113

5 years ago

0.0.112

5 years ago

0.0.111

5 years ago