Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client side normalization #120

Open
m1212e opened this issue Aug 1, 2024 · 0 comments
Open

Client side normalization #120

m1212e opened this issue Aug 1, 2024 · 0 comments

Comments

@m1212e
Copy link

m1212e commented Aug 1, 2024

Imagine following scenario:

I have an endpoint. I use normalization and accept a schema of

t.Object({ id: t.String() })

I can send along this body:

{ id: "123", name: "elysia" }

and it will work just fine since the name field will just be filtered out by normalization. Now imagine I do this with an array of thousands of entries. I send along more data than needed since the name will be stripped away anyways.

I had this which resulted in a 413 HTTP status.

It would be SO cool if the client would already strip away fields not matching the body schema. E.g. know about the schema and run a typebox Type.Clean() on the values. Currently, I don't think this is possible since the client is only instatiated with a generic TS type derived from the api elysia instance. But maybe if we would instantiate the client with a full instance, the client could read the schema of each endpoint and run a clean on the bodies? Is this practical/possible at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant