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
All is in the title. We need a way to handle this case out of the box.
For now we need to do several requests when having nested database model, this has a cost in term of performance and forces us to write more code and unnecessary queries to the database, whereas one unique query would be sufficient with this feature.
Here is a minimal reproduction that of course throw a validation error since Elysia is not handling this case.
import{treaty}from"@elysiajs/eden";import{describe,expect,it}from"bun:test";import{Elysia,t}from"elysia";constapp=newElysia().post("/",({ body })=>{// Anyway what is the logic here, error is happening at validation lifecycle since // Elysia is not parsing the body correctly in this casereturnbody;},{body: t.Object({name: t.String(),// variants is the nested attribute that needs to be parsed correctly by Elysia, without this, it will work.variants: t.Array(t.Object({price: t.Number({minimum: 0}),weight: t.Number({minimum: 0}),}),),// From the docs ->// By providing a file type, Elysia will automatically assume that the content-type is multipart/form-data.image: t.File({type: "image"}),}),},);constapi=treaty(app);consttestProduct={name: "Test Product",variants: [{price: 10,weight: 100,},],image: newFile(["dummy content"],"image1.webp",{type: "image/webp"}),};describe("Product POST/",()=>{it("should create a product using treaty",async()=>{const{ data, status, error }=awaitapi.index.post(testProduct);console.log("Error Value:",error?.value);console.log("Error Status:",error?.status);expect(status).toBe(200);expect(data).toEqual(testProduct);});});
What is the feature you are proposing to solve the problem?
I want Elysia to properly parse multipart/form-data requests when using nested body parameters. This should be the default behavior, as Elysia's type handling does not raise any issues when writing this code boilerplate.
What alternatives have you considered?
Doing multiple route, with multiple queries to my database.
The text was updated successfully, but these errors were encountered:
What is the problem this feature would solve?
All is in the title. We need a way to handle this case out of the box.
For now we need to do several requests when having nested database model, this has a cost in term of performance and forces us to write more code and unnecessary queries to the database, whereas one unique query would be sufficient with this feature.
Here is a minimal reproduction that of course throw a validation error since Elysia is not handling this case.
What is the feature you are proposing to solve the problem?
I want Elysia to properly parse multipart/form-data requests when using nested body parameters. This should be the default behavior, as Elysia's type handling does not raise any issues when writing this code boilerplate.
What alternatives have you considered?
Doing multiple route, with multiple queries to my database.
The text was updated successfully, but these errors were encountered: