Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@elysiajs/eden

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elysiajs/eden - npm Package Compare versions

Comparing version 0.2.0-rc.5 to 0.2.0-rc.6

dist/eden/src/index.d.ts

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class y{constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}addEventListener(e,t,s){return this.ws.addEventListener(e,i=>{if(e==="message"){let r=i.data.toString();const l=r.charCodeAt(0);if(l===47||l===123)try{r=JSON.parse(r)}catch{}else Number.isNaN(+r)?r==="true"?r=!0:r==="fase"&&(r=!1):r=+r;t({...i,data:r})}else t(i)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}}const w=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),p=(n,e,t)=>{if(n.endsWith("/")||(n+="/"),e=w(e.replace(/index/g,"")),!t||!Object.keys(t).length)return`${n}${e}`;let s="";for(const[i,r]of Object.entries(t))s+=`${i}=${r}&`;return`${n}${e}?${s.slice(0,-1)}`},v=(n,e="")=>new Proxy(()=>{},{get(t,s,i){return v(n,`${e}/${s.toString()}`)},apply(t,s,[{$query:i,$fetch:r,$body:l,...u}={$fetch:void 0,$query:void 0,$body:void 0}]=[{}]){const h=e.lastIndexOf("/"),d=e.slice(h+1),f=p(n,e.slice(0,h),i);if(d==="subscribe")return new y(f.replace(/^([^]+):\/\//,f.startsWith("https://")?"wss://":"ws://"));const o=l??(Object.keys(u).length?u:void 0);return fetch(f,{method:d,body:JSON.stringify(o),headers:o?{"content-type":typeof u=="object"?"application/json":"text/plain","content-length":o==null?void 0:o.length,...r==null?void 0:r.headers}:void 0,...r}).then(async c=>{var g;if(c.status>=300)throw new Error(await c.text());if((g=c.headers.get("content-type"))!=null&&g.includes("application/json"))try{return c.json()}catch{}const a=await c.text();return Number.isNaN(+a)?a==="true"?!0:a==="false"?!1:a:+a})}}),S=n=>new Proxy({},{get(e,t,s){return v(n,t)}});exports.EdenWS=y;exports.eden=S;
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class v{constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}addEventListener(e,t,s){return this.ws.addEventListener(e,i=>{if(e==="message"){let r=i.data.toString();const l=r.charCodeAt(0);if(l===47||l===123)try{r=JSON.parse(r)}catch{}else Number.isNaN(+r)?r==="true"?r=!0:r==="fase"&&(r=!1):r=+r;t({...i,data:r})}else t(i)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}}const b=n=>n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),p=(n,e,t)=>{if(n.endsWith("/")||(n+="/"),e=b(e.replace(/index/g,"")),!t||!Object.keys(t).length)return`${n}${e}`;let s="";for(const[i,r]of Object.entries(t))s+=`${i}=${r}&`;return`${n}${e}?${s.slice(0,-1)}`},w=(n,e="")=>new Proxy(()=>{},{get(t,s,i){return w(n,`${e}/${s.toString()}`)},apply(t,s,[{$query:i,$fetch:r,$body:l,...f}={$fetch:void 0,$query:void 0,$body:void 0}]=[{}]){const h=e.lastIndexOf("/"),d=e.slice(h+1),u=p(n,e.slice(0,h),i);if(d==="subscribe")return new v(u.replace(/^([^]+):\/\//,u.startsWith("https://")?"wss://":"ws://"));const o=l??(Object.keys(f).length?f:void 0),g=typeof o=="object";return fetch(u,{method:d,body:g?JSON.stringify(o):o,headers:o?{"content-type":g?"application/json":"text/plain","content-length":o==null?void 0:o.length,...r==null?void 0:r.headers}:void 0,...r}).then(async c=>{var y;if(c.status>300)throw new Error(await c.text());if((y=c.headers.get("content-type"))!=null&&y.includes("application/json"))try{return await c.json()}catch{}let a=await c.text();return Number.isNaN(+a)?a==="true"?!0:a==="false"?!1:a:+a})}}),S=n=>new Proxy({},{get(e,t,s){return w(n,t)}});exports.EdenWS=v;exports.eden=S;

@@ -1,1 +0,1 @@

(function(o,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(o=typeof globalThis<"u"?globalThis:o||self,c(o["@elysia/eden"]={}))})(this,function(o){"use strict";class c{constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}addEventListener(e,t,s){return this.ws.addEventListener(e,i=>{if(e==="message"){let n=i.data.toString();const a=n.charCodeAt(0);if(a===47||a===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="fase"&&(n=!1):n=+n;t({...i,data:n})}else t(i)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}}const w=r=>r.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),S=(r,e,t)=>{if(r.endsWith("/")||(r+="/"),e=w(e.replace(/index/g,"")),!t||!Object.keys(t).length)return`${r}${e}`;let s="";for(const[i,n]of Object.entries(t))s+=`${i}=${n}&`;return`${r}${e}?${s.slice(0,-1)}`},g=(r,e="")=>new Proxy(()=>{},{get(t,s,i){return g(r,`${e}/${s.toString()}`)},apply(t,s,[{$query:i,$fetch:n,$body:a,...d}={$fetch:void 0,$query:void 0,$body:void 0}]=[{}]){const y=e.lastIndexOf("/"),p=e.slice(y+1),h=S(r,e.slice(0,y),i);if(p==="subscribe")return new c(h.replace(/^([^]+):\/\//,h.startsWith("https://")?"wss://":"ws://"));const u=a??(Object.keys(d).length?d:void 0);return fetch(h,{method:p,body:JSON.stringify(u),headers:u?{"content-type":typeof d=="object"?"application/json":"text/plain","content-length":u==null?void 0:u.length,...n==null?void 0:n.headers}:void 0,...n}).then(async f=>{var v;if(f.status>=300)throw new Error(await f.text());if((v=f.headers.get("content-type"))!=null&&v.includes("application/json"))try{return f.json()}catch{}const l=await f.text();return Number.isNaN(+l)?l==="true"?!0:l==="false"?!1:l:+l})}}),b=r=>new Proxy({},{get(e,t,s){return g(r,t)}});o.EdenWS=c,o.eden=b,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
(function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o["@elysia/eden"]={}))})(this,function(o){"use strict";class a{constructor(e){this.ws=new WebSocket(e),this.url=e}send(e){return Array.isArray(e)?(e.forEach(t=>this.send(t)),this):(this.ws.send(typeof e=="object"?JSON.stringify(e):e.toString()),this)}on(e,t,s){return this.addEventListener(e,t,s)}off(e,t,s){return this.ws.removeEventListener(e,t,s),this}addEventListener(e,t,s){return this.ws.addEventListener(e,i=>{if(e==="message"){let n=i.data.toString();const l=n.charCodeAt(0);if(l===47||l===123)try{n=JSON.parse(n)}catch{}else Number.isNaN(+n)?n==="true"?n=!0:n==="fase"&&(n=!1):n=+n;t({...i,data:n})}else t(i)},s),this}removeEventListener(e,t,s){return this.off(e,t,s),this}close(){return this.ws.close(),this}}const b=r=>r.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),S=(r,e,t)=>{if(r.endsWith("/")||(r+="/"),e=b(e.replace(/index/g,"")),!t||!Object.keys(t).length)return`${r}${e}`;let s="";for(const[i,n]of Object.entries(t))s+=`${i}=${n}&`;return`${r}${e}?${s.slice(0,-1)}`},h=(r,e="")=>new Proxy(()=>{},{get(t,s,i){return h(r,`${e}/${s.toString()}`)},apply(t,s,[{$query:i,$fetch:n,$body:l,...y}={$fetch:void 0,$query:void 0,$body:void 0}]=[{}]){const g=e.lastIndexOf("/"),p=e.slice(g+1),d=S(r,e.slice(0,g),i);if(p==="subscribe")return new a(d.replace(/^([^]+):\/\//,d.startsWith("https://")?"wss://":"ws://"));const c=l??(Object.keys(y).length?y:void 0),v=typeof c=="object";return fetch(d,{method:p,body:v?JSON.stringify(c):c,headers:c?{"content-type":v?"application/json":"text/plain","content-length":c==null?void 0:c.length,...n==null?void 0:n.headers}:void 0,...n}).then(async u=>{var w;if(u.status>300)throw new Error(await u.text());if((w=u.headers.get("content-type"))!=null&&w.includes("application/json"))try{return await u.json()}catch{}let f=await u.text();return Number.isNaN(+f)?f==="true"?!0:f==="false"?!1:f:+f})}}),j=r=>new Proxy({},{get(e,t,s){return h(r,t)}});o.EdenWS=a,o.eden=j,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
{
"name": "@elysiajs/eden",
"version": "0.2.0-rc.5",
"version": "0.2.0-rc.6",
"description": "Fully type-safe Elysia client",

@@ -37,3 +37,3 @@ "author": {

"peerDependencies": {
"elysia": ">= 0.1.0"
"elysia": ">= 0.2.0-rc.1"
},

@@ -47,2 +47,3 @@ "devDependencies": {

"eslint": "^8.26.0",
"elysia": "^0.2.0-rc.1",
"rimraf": "^3.0.2",

@@ -49,0 +50,0 @@ "typescript": "^4.8.4",

@@ -157,12 +157,12 @@ import type { Elysia, TypedSchema, HTTPMethod } from 'elysia'

$body ?? (Object.keys(bodyObj).length ? bodyObj : undefined)
const isObject = typeof body === 'object'
return fetch(url, {
method,
body: JSON.stringify(body),
body: isObject ? JSON.stringify(body) : body,
headers: body
? {
'content-type':
typeof bodyObj === 'object'
? 'application/json'
: 'text/plain',
'content-type': isObject
? 'application/json'
: 'text/plain',
'content-length': body?.length,

@@ -174,3 +174,3 @@ ...$fetch?.['headers']

}).then(async (res) => {
if (res.status >= 300) throw new Error(await res.text())
if (res.status > 300) throw new Error(await res.text())

@@ -183,3 +183,3 @@ if (

try {
return res.json()
return await res.json()
} catch (_) {

@@ -190,9 +190,9 @@ // if json is error then it's string

const result = await res.text()
let data = await res.text()
if (!Number.isNaN(+result)) return +result
if (result === 'true') return true
if (result === 'false') return false
if (!Number.isNaN(+data)) return +data
if (data === 'true') return true
if (data === 'false') return false
return result
return data
})

@@ -199,0 +199,0 @@ }

@@ -1,4 +0,3 @@

import type { Elysia, SCHEMA, TypedRoute } from 'elysia'
import type { IsPathParameter } from 'elysia/dist/types'
import { TObject } from '@sinclair/typebox'
import type { Elysia, SCHEMA, TypedRoute, IsPathParameter } from 'elysia'
import type { TObject } from '@sinclair/typebox'

@@ -95,4 +94,12 @@ import type { EdenWS } from '.'

key extends string
? Server[Full][Uppercase<key>]['response']
: Server[Full][key]['response']
? Server[Full][Uppercase<key>]['response'] extends {
200: infer ReturnedType
}
? ReturnedType
: unknown
: Server[Full][key]['response'] extends {
200: infer ReturnedType
}
? ReturnedType
: unknown
>

@@ -127,3 +134,7 @@ : key extends 'subscribe'

? Uppercase<key>
: key]['response']
: key]['response'] extends {
200: infer ReturnedType
}
? ReturnedType
: unknown
>

@@ -130,0 +141,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc