You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Backend builds application, which is runnable + exposes object which is as const satisfies APIInfo.
This object is then used by FE to build full client.
Args for when FE building client:
URL prefix
Callback to get (auth) headers
Notice that this particular scenario we would end up importing Node things into FE package.
Because we want validation (= transformation) to also happen on FE end (e.g. to handle Date <-> string automatic translation by validation framework like io-ts and more recently, zod), we must get the validation objects to FE also (unlike Hono RPC which gets only typings, and has no runtime validation on FE side).
We might end up with something like this
// spec.ts, shared between BE and FEimporttype*astyrasfrom"@ty-ras/rest-api-io-ts";import*astfrom"io-ts";exportdefault{test: {another: {[tyras.GET]: {responseBody: t.string,},},[tyras.POST]: {responseBody: t.boolean,},},}asconstsatisfiestyras.APIInfo;
Ideas (big pic inspired by Hono RPC):
Package
@ty-ras/rest-api
(new)Something like this
And then
Package
@ty-ras/rest-api-io-ts
(new)Has
Consequentially, then
Package
@ty-ras/endpoint-spec
(pre-existing)The
ApplicationBuilderGeneric
would need to have something likeBackend builds application, which is runnable + exposes object which is
as const satisfies APIInfo
.This object is then used by FE to build full client.
Args for when FE building client:
Notice that this particular scenario we would end up importing Node things into FE package.
Because we want validation (= transformation) to also happen on FE end (e.g. to handle
Date
<->string
automatic translation by validation framework likeio-ts
and more recently,zod
), we must get the validation objects to FE also (unlike Hono RPC which gets only typings, and has no runtime validation on FE side).We might end up with something like this
This makes #72 obsolete
The text was updated successfully, but these errors were encountered: