@elysiajs/eden 0.1.0-rc.4 → 0.1.0
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.
- package/dist/index.js +1 -1
- package/dist/index.mjs +21 -18
- package/dist/index.umd.js +1 -1
- package/package.json +2 -3
- package/src/index.ts +7 -1
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),y=(t,e,r)=>{if(t.endsWith("/")||(t+="/"),e=g(e.replace(/index/g,"")),!r||!Object.keys(r).length)return`${t}${e}`;let n="";for(const[a,o]of Object.entries(r))n+=`${a}=${o}&`;return`${t}${e}?${n.slice(0,-1)}`},u=(t,e="")=>new Proxy(()=>{},{get(r,n,a){return u(t,`${e}/${n.toString()}`)},apply(r,n,[{$query:a,$fetch:o,...c}={$fetch:void 0,$query:void 0}]=[{}]){const l=e.lastIndexOf("/");return fetch(y(t,e.slice(0,l),a),{method:e.slice(l+1),headers:{"content-type":"application/json",...o==null?void 0:o.headers},body:Object.keys(c).length?JSON.stringify(c):void 0,...o}).then(async s=>{if(s.status>=300)throw new Error(await s.text());if(s.headers.get("content-type")==="application/json")return s.json();const i=await s.text();return Number.isNaN(+i)?i==="true"?!0:i==="false"?!1:i:+i})}}),f=t=>new Proxy({},{get(e,r,n){return u(t,r)}});exports.eden=f;
|
package/dist/index.mjs
CHANGED
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
const g = (t) => t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`),
|
|
2
|
-
if (t.endsWith("/") || (t += "/"), e = g(e.replace(/index/g, "")), !
|
|
1
|
+
const g = (t) => t.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), f = (t, e, r) => {
|
|
2
|
+
if (t.endsWith("/") || (t += "/"), e = g(e.replace(/index/g, "")), !r || !Object.keys(r).length)
|
|
3
3
|
return `${t}${e}`;
|
|
4
|
-
let
|
|
5
|
-
for (const [
|
|
6
|
-
|
|
7
|
-
return `${t}${e}?${
|
|
8
|
-
},
|
|
4
|
+
let n = "";
|
|
5
|
+
for (const [a, o] of Object.entries(r))
|
|
6
|
+
n += `${a}=${o}&`;
|
|
7
|
+
return `${t}${e}?${n.slice(0, -1)}`;
|
|
8
|
+
}, u = (t, e = "") => new Proxy(() => {
|
|
9
9
|
}, {
|
|
10
|
-
get(
|
|
11
|
-
return
|
|
10
|
+
get(r, n, a) {
|
|
11
|
+
return u(t, `${e}/${n.toString()}`);
|
|
12
12
|
},
|
|
13
|
-
apply(
|
|
14
|
-
{ $query:
|
|
13
|
+
apply(r, n, [
|
|
14
|
+
{ $query: a, $fetch: o, ...c } = {
|
|
15
15
|
$fetch: void 0,
|
|
16
16
|
$query: void 0
|
|
17
17
|
}
|
|
18
18
|
] = [{}]) {
|
|
19
|
-
const
|
|
20
|
-
return fetch(
|
|
21
|
-
method: e.slice(
|
|
19
|
+
const l = e.lastIndexOf("/");
|
|
20
|
+
return fetch(f(t, e.slice(0, l), a), {
|
|
21
|
+
method: e.slice(l + 1),
|
|
22
22
|
headers: {
|
|
23
23
|
"content-type": "application/json",
|
|
24
24
|
...o == null ? void 0 : o.headers
|
|
25
25
|
},
|
|
26
|
-
body: Object.keys(
|
|
26
|
+
body: Object.keys(c).length ? JSON.stringify(c) : void 0,
|
|
27
27
|
...o
|
|
28
28
|
}).then(async (s) => {
|
|
29
29
|
if (s.status >= 300)
|
|
30
30
|
throw new Error(await s.text());
|
|
31
|
-
|
|
31
|
+
if (s.headers.get("content-type") === "application/json")
|
|
32
|
+
return s.json();
|
|
33
|
+
const i = await s.text();
|
|
34
|
+
return Number.isNaN(+i) ? i === "true" ? !0 : i === "false" ? !1 : i : +i;
|
|
32
35
|
});
|
|
33
36
|
}
|
|
34
37
|
}), y = (t) => new Proxy(
|
|
35
38
|
{},
|
|
36
39
|
{
|
|
37
|
-
get(e,
|
|
38
|
-
return
|
|
40
|
+
get(e, r, n) {
|
|
41
|
+
return u(t, r);
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
);
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(r,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(r=typeof globalThis<"u"?globalThis:r||self,s(r["@elysia/eden"]={}))})(this,function(r){"use strict";const s=t=>t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),y=(t,e,n)=>{if(t.endsWith("/")||(t+="/"),e=s(e.replace(/index/g,"")),!n||!Object.keys(n).length)return`${t}${e}`;let o="";for(const[c,i]of Object.entries(n))o+=`${c}=${i}&`;return`${t}${e}?${o.slice(0,-1)}`},a=(t,e="")=>new Proxy(()=>{},{get(n,o,c){return a(t,`${e}/${o.toString()}`)},apply(n,o,[{$query:c,$fetch:i,...f}={$fetch:void 0,$query:void 0}]=[{}]){const d=e.lastIndexOf("/");return fetch(y(t,e.slice(0,d),c),{method:e.slice(d+1),headers:{"content-type":"application/json",...i==null?void 0:i.headers},body:Object.keys(f).length?JSON.stringify(f):void 0,...i}).then(async u=>{if(u.status>=300)throw new Error(await u.text());if(u.headers.get("content-type")==="application/json")return u.json();const l=await u.text();return Number.isNaN(+l)?l==="true"?!0:l==="false"?!1:l:+l})}}),g=t=>new Proxy({},{get(e,n,o){return a(t,n)}});r.eden=g,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elysiajs/eden",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Fully type-safe Elysia client",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "saltyAom",
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
"email": "saltyaom@gmail.com"
|
|
9
9
|
},
|
|
10
10
|
"main": "./dist/index.js",
|
|
11
|
-
"module": "./dist/index.mjs",
|
|
12
11
|
"exports": {
|
|
13
12
|
"require": "./dist/index.js",
|
|
14
13
|
"import": "./dist/index.mjs",
|
|
@@ -42,7 +41,7 @@
|
|
|
42
41
|
"@sinclair/typebox": "^0.25.13",
|
|
43
42
|
"@types/node": "^18.11.7",
|
|
44
43
|
"bun-types": "^0.3.0",
|
|
45
|
-
"elysia": "^0.1.0-rc.
|
|
44
|
+
"elysia": "^0.1.0-rc.8",
|
|
46
45
|
"eslint": "^8.26.0",
|
|
47
46
|
"rimraf": "^3.0.2",
|
|
48
47
|
"typescript": "^4.8.4",
|
package/src/index.ts
CHANGED
|
@@ -58,7 +58,13 @@ const createProxy = (
|
|
|
58
58
|
if (res.headers.get('content-type') === 'application/json')
|
|
59
59
|
return res.json()
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
const result = await res.text()
|
|
62
|
+
|
|
63
|
+
if (!Number.isNaN(+result)) return +result
|
|
64
|
+
if (result === 'true') return true
|
|
65
|
+
if (result === 'false') return false
|
|
66
|
+
|
|
67
|
+
return result
|
|
62
68
|
})
|
|
63
69
|
}
|
|
64
70
|
}) as unknown as Record<string, unknown>
|