Replies: 1 comment 2 replies
-
You should migrate to "contract-first" or maybe (I'm not try yet) convert router into json and use it as a "contract" |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I started exploring this lib yesterday.
Firts, I implemented the server router
a-la-trpc
, skipping the creation of a contract, i call this approachcode first
.Then I wanted to expose the server API with
OpenAPI
, so I started reading the docs.The docs (https://orpc.unnoq.com/docs/openapi/getting-started#defining-routes) explain to add
.route(...)
to procedures.With this change, I think that i can still use OpenAPI with an existing
code-first
approach.But...
...when I reached the "client" creation docs (https://orpc.unnoq.com/docs/openapi/client/openapi-link#setup), the example, that replaces
RPCLink
ofcode-first
approach withOpenAPILink
requires acontract
js object in the creation of the client.Obviously i don't want to expose server code into frontend so I don't want to do something like this
Questions
Now I'm thinking that in order to expose the server router via OpenAPI it's mandatory to use a "contract first" approach.
code-first
approach in the server, do I need to run a codegen/download step, to obtain a static filespec.json
(a "client-safe" json object of the OpenAPI spec) that I can use when creating the "browser" client? Is the only way?Beta Was this translation helpful? Give feedback.
All reactions