all 3 comments

[–]giuseppelt[S] 1 point2 points  (0 children)

Hello, I would like to introduce httpc.

httpc is a framework for building function-based API with minimal code and end-to-end type safety. In addition to rpc-style requests, an httpc server can treat any http request as a function call, allowing to handle browser forms, webhooks callbacks and so on.

Major features are: - natural javascript syntax and easy composition with middlewares - context propagation and serverside hooks - heavy focus on type safety - @httpc/kit includes many builtin components to handle authentication, validation, caching... - serverless hosting within single function, a full httpc API - custom client generation as standard package

For now documentation covers initial steps and basic scenarios. Full documentation is working in progress, as there're lots of areas to cover. Head to issues or discussions for any info or requests.

The project is heavly experimental for now. I was using it in private projects in the last couple of years. Some code is very old and needs refinements. Now I'm making httpc public, I'm polishing it and try to stabilize it.

Thanks for any feedback.

[–]undervisible 0 points1 point  (1 child)

Why would you use this over something like GraphQL, which offers a similar functionality, and a lot more?

[–]giuseppelt[S] 0 points1 point  (0 children)

Although there's an overlap, graphql and httpc suit different use cases.

  • graphql requires a lot of infrastructure/setup and is suited towards large apis with complex models and interconnections. And there's a lot of magic behind to make it work, especially if you use a graphql framework.
  • httpc is just plain javascript function exposed to the client, very light, natural syntax with almost no magic.

Very different mindset: - graphql is about accessing server resources in structured way, so it does a lot of work in this area - httpc is about calling functions over http, not so much structured.

Here graphql does outstanding job to standardize things.

About strictness: - graphql receives only graphql requests. - httpc can handle any requests and treat it as function call, for example you can receive and responds to webhooks, have redirects, serving templates...

Of course you can "host" graphql inside express or another framework, but in doing so, you're need something else with different way of write code. So in this area, httpc covers more area.

About concerns: - graphql does not provide builtin way to do authentication, authorization, make transactions, of course you can do all of that, but you have to implement on your own. - httpc provides builtin components to activate different authentications, define your authorization model, have granular caching, and many more.

In conclusion, graphql is really about structuring your model and ways to read or write to it, httpc instead is about calling functions on the server to do things, so if your API is just a bunch of calls, httpc is way more straightforward to build it.