@elysiajs/eden 0.6.0 → 0.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/errors.js +10 -0
  2. package/dist/errors.js.map +1 -0
  3. package/dist/fetch/index.js +64 -0
  4. package/dist/fetch/index.js.map +1 -0
  5. package/dist/fetch/types.js +2 -0
  6. package/dist/fetch/types.js.map +1 -0
  7. package/dist/fetch.js +1 -1
  8. package/dist/fetch.mjs +26 -16
  9. package/dist/fn/index.js +35 -0
  10. package/dist/fn/index.js.map +1 -0
  11. package/dist/fn/types.js +2 -0
  12. package/dist/fn/types.js.map +1 -0
  13. package/dist/fn/utils.js +59 -0
  14. package/dist/fn/utils.js.map +1 -0
  15. package/dist/index.js +25 -1
  16. package/dist/index.js.map +1 -0
  17. package/dist/index.mjs +1 -1
  18. package/dist/treaty/index.js +205 -0
  19. package/dist/treaty/index.js.map +1 -0
  20. package/dist/treaty/types.js +2 -0
  21. package/dist/treaty/types.js.map +1 -0
  22. package/dist/treaty/utils.js +13 -0
  23. package/dist/treaty/utils.js.map +1 -0
  24. package/dist/treaty.js +1 -1
  25. package/dist/treaty.mjs +108 -112
  26. package/dist/types.js +2 -0
  27. package/dist/types.js.map +1 -0
  28. package/package.json +5 -8
  29. package/src/fetch/index.ts +17 -6
  30. package/src/fetch/types.ts +33 -14
  31. package/src/fn/index.ts +1 -1
  32. package/src/fn/types.ts +1 -1
  33. package/src/treaty/index.ts +58 -53
  34. package/src/treaty/types.ts +117 -206
  35. package/src/types.ts +1 -1
  36. package/dist/fetch/index.d.ts +0 -5
  37. package/dist/fetch/index.d.ts.map +0 -1
  38. package/dist/fetch/types.d.ts +0 -36
  39. package/dist/fetch/types.d.ts.map +0 -1
  40. package/dist/fn/index.d.ts +0 -5
  41. package/dist/fn/index.d.ts.map +0 -1
  42. package/dist/fn/types.d.ts +0 -28
  43. package/dist/fn/types.d.ts.map +0 -1
  44. package/dist/fn/utils.d.ts +0 -14
  45. package/dist/fn/utils.d.ts.map +0 -1
  46. package/dist/index.d.ts +0 -4
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/treaty/index.d.ts +0 -18
  49. package/dist/treaty/index.d.ts.map +0 -1
  50. package/dist/treaty/utils.d.ts +0 -2
  51. package/dist/treaty/utils.d.ts.map +0 -1
  52. package/dist/types.d.ts +0 -26
  53. package/dist/types.d.ts.map +0 -1
  54. package/dist/utils.d.ts +0 -6
  55. package/dist/utils.d.ts.map +0 -1
  56. /package/dist/{utils-5a40996f.mjs → errors-5a40996f.mjs} +0 -0
  57. /package/dist/{utils-a2cfc56a.js → errors-a2cfc56a.js} +0 -0
  58. /package/src/{utils.ts → errors.ts} +0 -0
package/dist/treaty.mjs CHANGED
@@ -1,32 +1,34 @@
1
1
  var A = Object.defineProperty;
2
- var j = (r, e, t) => e in r ? A(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var g = (r, e, t) => (j(r, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { E as B } from "./utils-5a40996f.mjs";
5
- const P = (r, e, t) => {
6
- if (r.endsWith("/") || (r += "/"), e === "index" && (e = ""), !t || !Object.keys(t).length)
7
- return `${r}${e}`;
2
+ var O = (s, e, t) => e in s ? A(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
3
+ var b = (s, e, t) => (O(s, typeof e != "symbol" ? e + "" : e, t), t);
4
+ import { E as k } from "./errors-5a40996f.mjs";
5
+ const j = (s, e, t) => {
6
+ if (s.endsWith("/") || (s += "/"), e === "index" && (e = ""), !t || !Object.keys(t).length)
7
+ return `${s}${e}`;
8
8
  let n = "";
9
- for (const [a, s] of Object.entries(t))
10
- n += `${a}=${s}&`;
11
- return `${r}${e}?${n.slice(0, -1)}`;
12
- }, v = typeof FileList > "u", N = (r) => v ? r instanceof Blob : r instanceof FileList || r instanceof File, W = (r) => {
13
- for (const e in r) {
14
- if (N(r[e]))
9
+ for (const [o, r] of Object.entries(t))
10
+ n += `${o}=${r}&`;
11
+ return `${s}${e}?${n.slice(0, -1)}`;
12
+ }, g = typeof FileList > "u", L = (s) => g ? s instanceof Blob : s instanceof FileList || s instanceof File, B = (s) => {
13
+ if (!s)
14
+ return !1;
15
+ for (const e in s) {
16
+ if (L(s[e]))
15
17
  return !0;
16
- if (Array.isArray(r[e]) && r[e].find((t) => N(t)))
18
+ if (Array.isArray(s[e]) && s[e].find((t) => L(t)))
17
19
  return !0;
18
20
  }
19
21
  return !1;
20
- }, S = (r) => v ? r : new Promise((e) => {
22
+ }, N = (s) => g ? s : new Promise((e) => {
21
23
  const t = new FileReader();
22
24
  t.onload = () => {
23
- e(new Blob([t.result], { type: r.type }));
24
- }, t.readAsArrayBuffer(r);
25
+ e(new Blob([t.result], { type: s.type }));
26
+ }, t.readAsArrayBuffer(s);
25
27
  });
26
- class J {
28
+ class P {
27
29
  constructor(e) {
28
- g(this, "ws");
29
- g(this, "url");
30
+ b(this, "ws");
31
+ b(this, "url");
30
32
  this.ws = new WebSocket(e), this.url = e;
31
33
  }
32
34
  send(e) {
@@ -46,23 +48,23 @@ class J {
46
48
  addEventListener(e, t, n) {
47
49
  return this.ws.addEventListener(
48
50
  e,
49
- (a) => {
51
+ (o) => {
50
52
  if (e === "message") {
51
- let s = a.data.toString();
52
- const f = s.charCodeAt(0);
53
- if (f === 47 || f === 123)
53
+ let r = o.data.toString();
54
+ const c = r.charCodeAt(0);
55
+ if (c === 47 || c === 123)
54
56
  try {
55
- s = JSON.parse(s);
57
+ r = JSON.parse(r);
56
58
  } catch {
57
59
  }
58
60
  else
59
- Number.isNaN(+s) ? s === "true" ? s = !0 : s === "fase" && (s = !1) : s = +s;
61
+ Number.isNaN(+r) ? r === "true" ? r = !0 : r === "fase" && (r = !1) : r = +r;
60
62
  t({
61
- ...a,
62
- data: s
63
+ ...o,
64
+ data: r
63
65
  });
64
66
  } else
65
- t(a);
67
+ t(o);
66
68
  },
67
69
  n
68
70
  ), this;
@@ -74,104 +76,98 @@ class J {
74
76
  return this.ws.close(), this;
75
77
  }
76
78
  }
77
- const O = (r, e = "", t) => (
78
- // eslint-disable-next-line @typescript-eslint/no-empty-function
79
- new Proxy(() => {
80
- }, {
81
- get(n, a, s) {
82
- return O(r, `${e}/${a.toString()}`, t);
83
- },
84
- apply(n, a, [
85
- { $query: s, $fetch: f, $body: k, ...E } = {
86
- $fetch: void 0,
87
- $query: void 0,
88
- $body: void 0
89
- }
90
- ] = [{}]) {
91
- const F = e.lastIndexOf("/"), $ = e.slice(F + 1), h = P(r, e.slice(0, F), s);
92
- if ($ === "subscribe")
93
- return new J(
94
- h.replace(
95
- /^([^]+):\/\//,
96
- h.startsWith("https://") ? "wss://" : "ws://"
97
- )
98
- );
99
- const y = async () => {
100
- var x, L;
101
- let c = k ?? (Object.keys(E).length ? E : void 0);
102
- const w = typeof c == "object", m = w && W(c);
103
- if (m) {
104
- const o = new FormData();
105
- for (const [d, l] of Object.entries(c))
106
- if (v)
107
- o.append(d, l);
79
+ const S = (s, e = "", t) => new Proxy(() => {
80
+ }, {
81
+ get(n, o, r) {
82
+ return S(s, `${e}/${o.toString()}`, t);
83
+ },
84
+ apply(n, o, [
85
+ { $query: r, $fetch: c, $headers: $, ...E } = {
86
+ $fetch: void 0,
87
+ $headers: void 0,
88
+ $query: void 0
89
+ }
90
+ ] = [{}]) {
91
+ const F = e.lastIndexOf("/"), h = e.slice(F + 1), w = j(s, e.slice(0, F), r);
92
+ return h === "subscribe" ? new P(
93
+ w.replace(
94
+ /^([^]+):\/\//,
95
+ w.startsWith("https://") ? "wss://" : "ws://"
96
+ )
97
+ ) : (async () => {
98
+ var m, x;
99
+ let f;
100
+ const v = {
101
+ ...(m = t.$fetch) == null ? void 0 : m.headers,
102
+ ...c == null ? void 0 : c.headers,
103
+ ...$
104
+ };
105
+ if (h !== "GET" && h !== "HEAD") {
106
+ f = Object.keys(E).length ? E : void 0;
107
+ const a = typeof f == "object";
108
+ if (a && B(f)) {
109
+ const d = new FormData();
110
+ for (const [y, l] of Object.entries(f))
111
+ if (g)
112
+ d.append(y, l);
108
113
  else if (l instanceof File)
109
- o.append(
110
- d,
111
- await S(l)
114
+ d.append(
115
+ y,
116
+ await N(l)
112
117
  );
113
118
  else if (l instanceof FileList)
114
- for (let b = 0; b < l.length; b++)
115
- o.append(
116
- d,
117
- await S(l[b])
119
+ for (let p = 0; p < l.length; p++)
120
+ d.append(
121
+ y,
122
+ await N(l[p])
118
123
  );
119
124
  else
120
- o.append(d, l);
121
- c = o;
125
+ d.append(y, l);
126
+ f = d;
122
127
  } else
123
- w && (c = JSON.stringify(c));
124
- const p = {
125
- ...(x = t.$fetch) == null ? void 0 : x.headers,
126
- ...f == null ? void 0 : f.headers
127
- }, i = await (t.fetcher ?? fetch)(h, {
128
- method: $,
129
- body: c,
130
- ...t.$fetch,
131
- ...f,
132
- headers: c ? m ? p : {
133
- "content-type": w ? "application/json" : "text/plain",
134
- ...p
135
- } : p
136
- });
137
- let u;
138
- switch ((L = i.headers.get("Content-Type")) == null ? void 0 : L.split(";")[0]) {
139
- case "application/json":
140
- u = await i.json();
141
- break;
142
- default:
143
- u = await i.text().then((o) => Number.isNaN(+o) ? o === "true" ? !0 : o === "false" ? !1 : o : +o);
144
- }
145
- return i.status > 300 ? {
146
- data: u,
147
- error: new B(i.status, await u),
148
- status: i.status,
149
- raw: i,
150
- headers: i.headers,
151
- retry: y
152
- } : {
153
- data: u,
154
- status: i.status,
155
- raw: i,
156
- headers: i.headers,
157
- error: null,
158
- retry: y
159
- };
128
+ v["content-type"] = a ? "application/json" : "text/plain", a && (f = JSON.stringify(f));
129
+ }
130
+ const i = await (t.fetcher ?? fetch)(w, {
131
+ method: h,
132
+ body: f,
133
+ ...t.$fetch,
134
+ ...c,
135
+ headers: v
136
+ });
137
+ let u;
138
+ switch ((x = i.headers.get("Content-Type")) == null ? void 0 : x.split(";")[0]) {
139
+ case "application/json":
140
+ u = await i.json();
141
+ break;
142
+ default:
143
+ u = await i.text().then((a) => Number.isNaN(+a) ? a === "true" ? !0 : a === "false" ? !1 : a : +a);
144
+ }
145
+ return i.status > 300 ? {
146
+ data: u,
147
+ error: new k(i.status, await u),
148
+ status: i.status,
149
+ raw: i,
150
+ headers: i.headers
151
+ } : {
152
+ data: u,
153
+ status: i.status,
154
+ response: i,
155
+ headers: i.headers,
156
+ error: null
160
157
  };
161
- return y();
162
- }
163
- })
164
- ), D = (r, e = {
158
+ })();
159
+ }
160
+ }), C = (s, e = {
165
161
  fetcher: fetch
166
162
  }) => new Proxy(
167
163
  {},
168
164
  {
169
165
  get(t, n) {
170
- return O(r, n, e);
166
+ return S(s, n, e);
171
167
  }
172
168
  }
173
169
  );
174
170
  export {
175
- J as EdenWS,
176
- D as edenTreaty
171
+ P as EdenWS,
172
+ C as edenTreaty
177
173
  };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elysiajs/eden",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "Fully type-safe Elysia client",
5
5
  "author": {
6
6
  "name": "saltyAom",
@@ -58,9 +58,7 @@
58
58
  "release": "npm run build && npm run test && npm publish --access public"
59
59
  },
60
60
  "peerDependencies": {
61
- "@elysiajs/fn": ">= 0.5.0",
62
- "@sinclair/typebox": ">= 0.28.10",
63
- "elysia": ">= 0.5.0"
61
+ "elysia": ">= 0.6.7"
64
62
  },
65
63
  "peerDependenciesMeta": {
66
64
  "@sinclair/typebox": {
@@ -68,16 +66,15 @@
68
66
  }
69
67
  },
70
68
  "devDependencies": {
71
- "@elysiajs/cors": "0.5.0",
69
+ "@elysiajs/cors": "0.6.0",
72
70
  "@elysiajs/fn": "^0.6.1",
73
71
  "@sinclair/typebox": "^0.26.8",
74
72
  "@types/node": "^18.15.5",
75
- "bun-types": "^0.5.8",
76
- "elysia": "0.6.0",
73
+ "elysia": "0.6.10",
77
74
  "eslint": "^8.26.0",
78
75
  "rimraf": "^4.4.1",
79
76
  "typescript": "^5.0.4",
80
- "vite": "^4.3.5",
77
+ "vite": "^4.4.9",
81
78
  "vite-plugin-dts": "^2.3.0"
82
79
  },
83
80
  "dependencies": {
@@ -1,19 +1,19 @@
1
1
  import type { Elysia } from 'elysia'
2
2
 
3
- import { EdenFetchError } from '../utils'
3
+ import { EdenFetchError } from '../errors'
4
4
  import type { EdenFetch } from './types'
5
5
  export type { EdenFetch } from './types'
6
6
 
7
7
  export const edenFetch =
8
- <App extends Elysia<any>>(
8
+ <App extends Elysia<any, any>>(
9
9
  server: string,
10
10
  config?: EdenFetch.Config
11
11
  ): EdenFetch.Create<App> =>
12
12
  // @ts-ignore
13
- async (endpoint: string, { params, body, ...options } = {}) => {
13
+ (endpoint: string, { params, body, ...options } = {}) => {
14
14
  if (params)
15
15
  Object.entries(params).forEach(([key, value]) => {
16
- endpoint = endpoint.replace(`:${key}`, value)
16
+ endpoint = endpoint.replace(`:${key}`, value as string)
17
17
  })
18
18
 
19
19
  const contentType = options.headers?.['Content-Type']
@@ -28,7 +28,7 @@ export const edenFetch =
28
28
  const fetch = config?.fetcher || globalThis.fetch
29
29
 
30
30
  // @ts-ignore
31
- return fetch(server + endpoint, {
31
+ const execute = () => fetch(server + endpoint, {
32
32
  ...options,
33
33
  headers: body
34
34
  ? {
@@ -59,9 +59,20 @@ export const edenFetch =
59
59
  if (res.status > 300)
60
60
  return {
61
61
  data: null,
62
+ status: res.status,
63
+ headers: res.headers,
64
+ retry: execute,
62
65
  error: new EdenFetchError(res.status, data)
63
66
  }
64
67
 
65
- return { data, error: null }
68
+ return {
69
+ data,
70
+ error: null,
71
+ status: res.status,
72
+ headers: res.headers,
73
+ retry: execute
74
+ }
66
75
  })
76
+
77
+ return execute()
67
78
  }
@@ -1,9 +1,13 @@
1
1
  import type { Elysia } from 'elysia'
2
- import type { EdenFetchError } from '../utils'
2
+ import type { EdenFetchError } from '../errors'
3
3
  import type { MapError, IsUnknown, IsNever } from '../types'
4
4
 
5
+ type Prettify<T> = {
6
+ [K in keyof T]: T[K]
7
+ } & {}
8
+
5
9
  export namespace EdenFetch {
6
- export type Create<App extends Elysia<any>> = App['meta'] extends {
10
+ export type Create<App extends Elysia<any, any>> = App['meta'] extends {
7
11
  schema: infer Schema extends Record<string, any>
8
12
  }
9
13
  ? EdenFetch.Fn<Schema>
@@ -34,6 +38,13 @@ export namespace EdenFetch {
34
38
  : {
35
39
  params: Route['params']
36
40
  }) &
41
+ (IsNever<keyof Route['query']> extends true
42
+ ? {
43
+ query?: Record<never, string>
44
+ }
45
+ : {
46
+ query: Route['query']
47
+ }) &
37
48
  (undefined extends Route['headers']
38
49
  ? {
39
50
  headers?: Record<string, string>
@@ -45,17 +56,25 @@ export namespace EdenFetch {
45
56
  ? { body: Route['body'] }
46
57
  : { body?: unknown })
47
58
  ) => Promise<
48
- | {
49
- data: Awaited<Route['response']['200']>
50
- error: null
51
- }
52
- | {
53
- data: null
54
- error: MapError<Route['response']> extends infer Errors
55
- ? IsNever<Errors> extends true
56
- ? EdenFetchError<number, string>
57
- : Errors
58
- : EdenFetchError<number, string>
59
- }
59
+ Prettify<
60
+ (
61
+ | {
62
+ data: Awaited<Route['response']['200']>
63
+ error: null
64
+ }
65
+ | {
66
+ data: null
67
+ error: MapError<Route['response']> extends infer Errors
68
+ ? IsNever<Errors> extends true
69
+ ? EdenFetchError<number, string>
70
+ : Errors
71
+ : EdenFetchError<number, string>
72
+ }
73
+ ) & {
74
+ status: number
75
+ response: Response
76
+ headers: Record<string, string>
77
+ }
78
+ >
60
79
  >
61
80
  }
package/src/fn/index.ts CHANGED
@@ -47,7 +47,7 @@ const createProxy = (
47
47
  }
48
48
  }) as any
49
49
 
50
- export const edenFn = <App extends Elysia<any>>(
50
+ export const edenFn = <App extends Elysia<any, any>>(
51
51
  domain: string,
52
52
  config?: EdenFn.Config
53
53
  ): EdenFn.Create<App> =>
package/src/fn/types.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { Elysia } from 'elysia'
2
2
 
3
3
  export namespace EdenFn {
4
- export type Create<App extends Elysia<any>> = App['meta'] extends {
4
+ export type Create<App extends Elysia<any, any>> = App['meta'] extends {
5
5
  exposed: infer Schema extends Record<string, any>
6
6
  }
7
7
  ? EdenFn.Compose<Schema>
@@ -1,6 +1,6 @@
1
1
  import type { Elysia, TypedSchema } from 'elysia'
2
2
 
3
- import { EdenFetchError } from '../utils'
3
+ import { EdenFetchError } from '../errors'
4
4
 
5
5
  import { composePath } from './utils'
6
6
  import type { EdenTreaty } from './types'
@@ -22,6 +22,8 @@ const isFile = (v: any) => {
22
22
 
23
23
  // FormData is 1 level deep
24
24
  const hasFile = (obj: Record<string, any>) => {
25
+ if (!obj) return false
26
+
25
27
  for (const key in obj) {
26
28
  if (isFile(obj[key])) return true
27
29
  else if (
@@ -155,7 +157,6 @@ const createProxy = (
155
157
  path = '',
156
158
  config: EdenTreaty.Config
157
159
  ): Record<string, unknown> =>
158
- // eslint-disable-next-line @typescript-eslint/no-empty-function
159
160
  new Proxy(() => {}, {
160
161
  get(target, key, value) {
161
162
  return createProxy(domain, `${path}/${key.toString()}`, config)
@@ -164,12 +165,17 @@ const createProxy = (
164
165
  target,
165
166
  _,
166
167
  [
167
- { $query, $fetch, $body, ...bodyObj } = {
168
+ { $query, $fetch, $headers, ...bodyObj } = {
168
169
  $fetch: undefined,
169
- $query: undefined,
170
- $body: undefined
170
+ $headers: undefined,
171
+ $query: undefined
171
172
  }
172
- ]: EdenTreaty.CallOption[] = [{}]
173
+ ]: {
174
+ [x: string]: any
175
+ $fetch?: RequestInit
176
+ $headers?: HeadersInit
177
+ $query?: Record<string, string>
178
+ }[] = [{}]
173
179
  ) {
174
180
  const i = path.lastIndexOf('/'),
175
181
  method = path.slice(i + 1),
@@ -184,44 +190,54 @@ const createProxy = (
184
190
  )
185
191
 
186
192
  const execute = async () => {
187
- let body =
188
- $body ?? (Object.keys(bodyObj).length ? bodyObj : undefined)
189
- const isObject = typeof body === 'object'
190
- const isFormData = isObject && hasFile(body)
191
-
192
- if (isFormData) {
193
- const newBody = new FormData()
194
-
195
- // FormData is 1 level deep
196
- for (const [key, field] of Object.entries(body)) {
197
- if (isServer) {
198
- newBody.append(key, field as any)
199
- } else {
200
- // @ts-ignore
201
- if (field instanceof File)
202
- newBody.append(
203
- key,
204
- await fileToBlob(field as any)
205
- )
206
- // @ts-ignore
207
- else if (field instanceof FileList) {
193
+ let body: any
194
+
195
+ const headers = {
196
+ ...config.$fetch?.headers,
197
+ ...$fetch?.headers,
198
+ ...$headers
199
+ } as Record<string, string>
200
+
201
+ if (method !== 'GET' && method !== 'HEAD') {
202
+ body = Object.keys(bodyObj).length ? bodyObj : undefined
203
+ const isObject = typeof body === 'object'
204
+ const isFormData = isObject && hasFile(body)
205
+
206
+ if (isFormData) {
207
+ const newBody = new FormData()
208
+
209
+ // FormData is 1 level deep
210
+ for (const [key, field] of Object.entries(body)) {
211
+ if (isServer) {
212
+ newBody.append(key, field as any)
213
+ } else {
208
214
  // @ts-ignore
209
- for (let i = 0; i < field.length; i++) {
215
+ if (field instanceof File)
210
216
  newBody.append(
211
- key as any,
212
- await fileToBlob((field as any)[i])
217
+ key,
218
+ await fileToBlob(field as any)
213
219
  )
214
- }
215
- } else newBody.append(key, field as string)
220
+ // @ts-ignore
221
+ else if (field instanceof FileList) {
222
+ // @ts-ignore
223
+ for (let i = 0; i < field.length; i++) {
224
+ newBody.append(
225
+ key as any,
226
+ await fileToBlob((field as any)[i])
227
+ )
228
+ }
229
+ } else newBody.append(key, field as string)
230
+ }
216
231
  }
217
- }
218
232
 
219
- body = newBody
220
- } else if (isObject) body = JSON.stringify(body)
233
+ body = newBody
234
+ } else {
235
+ headers['content-type'] = isObject
236
+ ? 'application/json'
237
+ : 'text/plain'
221
238
 
222
- const $headers = {
223
- ...config.$fetch?.headers,
224
- ...$fetch?.headers
239
+ if (isObject) body = JSON.stringify(body)
240
+ }
225
241
  }
226
242
 
227
243
  const response = await (config.fetcher ?? fetch)(url, {
@@ -229,16 +245,7 @@ const createProxy = (
229
245
  body,
230
246
  ...config.$fetch,
231
247
  ...$fetch,
232
- headers: body
233
- ? isFormData
234
- ? $headers
235
- : {
236
- 'content-type': isObject
237
- ? 'application/json'
238
- : 'text/plain',
239
- ...$headers
240
- }
241
- : $headers
248
+ headers
242
249
  })
243
250
 
244
251
  let data
@@ -265,16 +272,14 @@ const createProxy = (
265
272
  status: response.status,
266
273
  raw: response,
267
274
  headers: response.headers,
268
- retry: execute
269
275
  }
270
276
 
271
277
  return {
272
278
  data,
273
279
  status: response.status,
274
- raw: response,
280
+ response: response,
275
281
  headers: response.headers,
276
- error: null,
277
- retry: execute
282
+ error: null as null
278
283
  }
279
284
  }
280
285
 
@@ -282,7 +287,7 @@ const createProxy = (
282
287
  }
283
288
  }) as unknown as Record<string, unknown>
284
289
 
285
- export const edenTreaty = <App extends Elysia<any>>(
290
+ export const edenTreaty = <App extends Elysia<any, any>>(
286
291
  domain: string,
287
292
  config: EdenTreaty.Config = {
288
293
  fetcher: fetch