Closed tqma113 closed 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.
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
.
Maybe we can take these steps:
farrow-api-client
in code-gen
of farrow-api
opt-in, the core of code-gen
is belong to farrow-api
farrow-api-server
pass its options to code-gen
function came from farrow-api
as a adapter.farrow-api-client
only use the types
from farrow-api-server
, it does not matter with farrow-api
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
farrow-api
does not depends onfarrow-api-client
(Of course should not depend on), but the generated code of it uses thefarrow-api-client
. Maybe The code of code generation for client should be infarrow-api-server
not thefarrow-api
.https://github.com/farrow-js/farrow/blob/master/packages/farrow-api/src/codegen.ts