DenisFrezzato / hyper-ts

Type safe middleware architecture for HTTP servers
https://denisfrezzato.github.io/hyper-ts/
MIT License
391 stars 18 forks source link

Avoid intermediate Location type in the fp-ts-routing example #72

Closed thewilkybarkid closed 2 years ago

thewilkybarkid commented 2 years ago

Following a conversation with my colleague @erkannt about using the fp-ts-routing library with and without hyper-ts, I've thought about how to avoid the Location type in the example here.

With https://github.com/gcanti/fp-ts-routing/pull/47 we can use inference to avoid having to declare the type (an altW would have avoided it too); the switch itself can be avoided by returning a middleware directly from the router (similar to how the routers in Express and Koa work).

Also, I've been thinking about releasing this as a hyper-ts-routing library. I really don't mind if this PR is merged or not, but I'd be interested to know any thoughts on this approach and whether it's useful for others.

DenisFrezzato commented 2 years ago

Also, I've been thinking about releasing this as a hyper-ts-routing library. I really don't mind if this PR is merged or not, but I'd be interested to know any thoughts on this approach and whether it's useful for others.

I've been thinking of such a library too, but I wasn't sure "how much" to put in there in order to be less opinionated as possible.

thewilkybarkid commented 2 years ago

@DenisFrezzato I've been using https://github.com/PREreview/prereview-display-prototype/blob/025b2a433abd75c9f13da91108c2e440f140d7a6/packages/hyper-ts-routing/src/routing.ts locally, how does that look?

thewilkybarkid commented 2 years ago

@DenisFrezzato I've released a less opinionated version at https://github.com/thewilkybarkid/hyper-ts-routing.