farrow-js / farrow

A Type-Friendly Web Framework for Node.js
https://www.farrowjs.com
MIT License
770 stars 37 forks source link

Adjustment Request: the code of code generation for client should be in farrow-api-client not the farrow-api #165

Closed tqma113 closed 2 years ago

tqma113 commented 2 years ago

farrow-api does not depends on farrow-api-client(Of course should not depend on), but the generated code of it uses the farrow-api-client. Maybe The code of code generation for client should be in farrow-api-server not the farrow-api.

https://github.com/farrow-js/farrow/blob/master/packages/farrow-api/src/codegen.ts

Lucifier129 commented 2 years ago

It depends on what do we think about code-gen.

If we think code-gen is the feature of server, it should belong to farrow-api-server.

If we think code-gen does not tie to an HTTP server, it's the ability of farrow-api, it should belong to farrow-api itself, not the consumer side, but the provider side.

tqma113 commented 2 years ago

farrow-client-api is hard to say without depending on farrow-server-api for now.

Actually farrow-server-api is a dependencies of farrow-client-api, it marked in package.json of farrow-api-client.

In addition, the requests sent by farrow-client-api have too many features of farrow-server-api, SingleCall BatchCall, Introspect, etc.

So my opinion is move the code of client code generation to farrow-server-api.

Lucifier129 commented 2 years ago

Maybe we can take these steps:

We can split code-gen into two parts:

The definition parts live in farrow-api will be good. farrow-api-server as one of adapters for HTTP Server via Farrow, but there can be other adapters like farrow-api-web-socket or farrow-api-grpc