elysia-xml
The library for elysia which allows you to work with XML
Installation
bun install elysia-xml
Usage
import Elysia from "elysia"
import { xml } from "elysia-xml"
new Elysia()
.use(xml())
.post("/", ({ body }) => {
return {
some: "values",
and: true,
keys: 228,
}
})
.listen(3000)
Use xml decorator
You can also use the xml method to force xml to be returned.
new Elysia().use(xml()).post("/", ({ xml }) =>
xml({
some: "values",
and: true,
keys: 228,
})
);
This method return Response
Output
<some>values</some>
<and>true</and>
<keys>228</keys>
Options
| builder? | XmlBuilderOptions | | Options to configure XML builder |
| parser? | X2jOptions | | Options to configure XML parser |
| contentTypes? | string[] | ["text/xml", "application/xml", "application/rss+xml"] | An array of content-types that need to be serialized/deserialized |
| force? | boolean | false | Don't look at the accept header to serialize? |
| transformResponse? | (value: any) => any | | Handler to transform response |
| as? | LifeCycleType | "scoped" | Option to specify type of hooks |
Thanks