0.4.119 • Published 1 year ago

@http4t/bidi v0.4.119

Weekly downloads
54
License
Apache-2.0
Repository
-
Last release
1 year 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

1 year ago

0.4.109

1 year ago

0.4.110

1 year ago

0.3.63

2 years ago

0.3.62

2 years ago

0.2.61

3 years ago

0.1.49

3 years ago

0.1.45

3 years ago

0.1.46

3 years ago

0.1.47

3 years ago

0.1.48

3 years ago

0.1.38

3 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.34

3 years ago

0.1.35

3 years ago

0.1.37

3 years ago

0.1.29

3 years ago

0.1.28

3 years ago

0.1.27

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.19

3 years ago

0.0.158

4 years ago

0.0.156

4 years ago

0.0.155

4 years ago

0.0.153

4 years ago

0.0.152

4 years ago

0.0.151

4 years ago

0.0.150

4 years ago

0.0.149

4 years ago

0.0.148

4 years ago

0.0.145

4 years ago

0.0.144

4 years ago

0.0.143

4 years ago

0.0.142

4 years ago

0.0.141

4 years ago

0.0.140

4 years ago

0.0.139

4 years ago

0.0.128

4 years ago

0.0.138

4 years ago

0.0.137

4 years ago

0.0.129

4 years ago

0.0.131

4 years ago

0.0.130

4 years ago

0.0.123

4 years ago

0.0.122

4 years ago

0.0.121

4 years ago

0.0.119

4 years ago

0.0.117

4 years ago

0.0.118

4 years ago

0.0.114

4 years ago

0.0.113

4 years ago

0.0.112

4 years ago

0.0.111

4 years ago