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

elysia

Package Overview
Dependencies
Maintainers
1
Versions
442
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elysia - npm Package Compare versions

Comparing version 0.5.0-exp-230427.1911 to 0.5.0-exp-230427.2009

48

dist/compose.js

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

let e;import{parse as r}from"fast-querystring";import{mapEarlyResponse as t,mapResponse as s}from"./handler";import{SCHEMA as n,DEFS as a,createValidationError as o,removeHostnameRegex as c,removeFragmentRegex as l,removePathRegex as i,removeQueryRegex as u}from"./utils";import{mapErrorCode as f}from"./error";let d="AsyncFunction",p=e=>e.constructor.name===d,h=Bun?.Transpiler?new Bun.Transpiler({minifyWhitespace:!0,inline:!0,platform:"bun",allowBunRuntime:!0}):void 0;export const composeHandler=({method:e,hooks:c,validator:l,handler:i,handleError:u,meta:m})=>{let y="try {\n",$="GET"!==e||i.constructor.name===d||c.parse.length||c.afterHandle.find(p)||c.beforeHandle.find(p)||c.transform.find(p);if($){if(y+=`
let e;import{parse as r}from"fast-querystring";import{mapEarlyResponse as t,mapResponse as s}from"./handler";import{SCHEMA as a,DEFS as n,createValidationError as o,removeHostnameRegex as c,removeFragmentRegex as l,removePathRegex as i,removeQueryRegex as u}from"./utils";import{mapErrorCode as d}from"./error";let f="AsyncFunction",p=e=>e.constructor.name===f,h=Bun?.Transpiler?new Bun.Transpiler({minifyWhitespace:!0,inline:!0,platform:"bun",allowBunRuntime:!0}):void 0;export const composeHandler=({method:e,hooks:c,validator:l,handler:i,handleError:u,meta:m})=>{let y="try {\n",$="GET"!==e||i.constructor.name===f||c.parse.length||c.afterHandle.find(p)||c.beforeHandle.find(p)||c.transform.find(p);if($){if(y+=`
let contentType = c.request.headers.get('content-type');

@@ -44,3 +44,3 @@

}}
`}if(c?.transform)for(let e=0;e<c.transform.length;e++)y+=c.transform[e].constructor.name===d?`await transform[${e}](c);`:`transform[${e}](c);`;if(l&&(l.headers&&(y+=`
`}if(c?.transform)for(let e=0;e<c.transform.length;e++)y+=c.transform[e].constructor.name===f?`await transform[${e}](c);`:`transform[${e}](c);`;if(l&&(l.headers&&(y+=`
const h = {}

@@ -57,6 +57,6 @@ for (const key of c.request.headers.keys())

}
`),l.params&&(y+="if(params.Check(c.params) === false) { throw createValidationError('params', params, c.params) }"),l.query&&(y+="if(query.Check(c.query) === false) { throw createValidationError('params', query, c.query) }"),l.body&&(y+="if(body.Check(c.body) === false) { throw createValidationError('body', body, c.body) }")),c?.beforeHandle)for(let e=0;e<c.beforeHandle.length;e++){let r=`be${e}`;if(y+=(c.beforeHandle[e].constructor.name===d?`let ${r} = await beforeHandle[${e}](c);
`),l.params&&(y+="if(params.Check(c.params) === false) { throw createValidationError('params', params, c.params) }"),l.query&&(y+="if(query.Check(c.query) === false) { throw createValidationError('params', query, c.query) }"),l.body&&(y+="if(body.Check(c.body) === false) { throw createValidationError('body', body, c.body) }")),c?.beforeHandle)for(let e=0;e<c.beforeHandle.length;e++){let r=`be${e}`;if(y+=(c.beforeHandle[e].constructor.name===f?`let ${r} = await beforeHandle[${e}](c);
`:`let ${r} = beforeHandle[${e}](c);
`)+`if(${r} !== undefined) {
`,c?.afterHandle)for(let e=0;e<c.afterHandle.length;e++){let t=`af${e}`;y+=(c.afterHandle[e].constructor.name===d?`const ${t} = await afterHandle[${e}](c, ${r});
`,c?.afterHandle)for(let e=0;e<c.afterHandle.length;e++){let t=`af${e}`;y+=(c.afterHandle[e].constructor.name===f?`const ${t} = await afterHandle[${e}](c, ${r});
`:`const ${t} = afterHandle[${e}](c, ${r});

@@ -66,5 +66,5 @@ `)+`if(${t} !== undefined) { ${r} = ${t} }

`),y+=`return mapEarlyResponse(${r}, c.set)}
`}if(c?.afterHandle.length){y+=i.constructor.name===d?`let r = await handler(c);
`}if(c?.afterHandle.length){y+=i.constructor.name===f?`let r = await handler(c);
`:`let r = handler(c);
`;for(let e=0;e<c.afterHandle.length;e++){let r=`af${e}`;y+=c.afterHandle[e].constructor.name===d?`let ${r} = await afterHandle[${e}](c, r)
`;for(let e=0;e<c.afterHandle.length;e++){let r=`af${e}`;y+=c.afterHandle[e].constructor.name===f?`let ${r} = await afterHandle[${e}](c, r)
`:`let ${r} = afterHandle[${e}](c, r)

@@ -77,6 +77,6 @@ `,l.response?y+=`if(response[c.set.status]?.Check(${r}) === false) { throw createValidationError('response', response[c.set.status], ${r}) }

`),y+=`return mapResponse(r, c.set);
`}else l.response?y+=(i.constructor.name===d?`const r = await handler(c);
`}else l.response?y+=(i.constructor.name===f?`const r = await handler(c);
`:`const r = handler(c);
`)+`if(response[c.set.status]?.Check(r) === false) { throw createValidationError('response', response[c.set.status], r) }
`+"return mapResponse(r, c.set);":y+=i.constructor.name===d?"return handler(c).then((v) => mapResponse(v, c.set))":"return mapResponse(handler(c), c.set);";y+=`
`+"return mapResponse(r, c.set);":y+=i.constructor.name===f?"return handler(c).then((v) => mapResponse(v, c.set))":"return mapResponse(handler(c), c.set);";y+=`
} catch(error) {

@@ -131,5 +131,6 @@ ${$?"":"return (async () => {"}

},
meta,
SCHEMA,
DEFS
${m?`
meta,
SCHEMA,
DEFS,`:""}
} = hooks

@@ -141,3 +142,3 @@

${y}
}`,h&&(y=h.transformSync(y));let q=Function("hooks",y);return q({handler:i,hooks:c,validator:l,handleError:u,utils:{createValidationError:o,mapResponse:s,mapEarlyResponse:t,mapErrorCode:f,parseQuery:r},meta:m,SCHEMA:n,DEFS:a})};export const composeGeneralHandler=s=>{let n=s.decorators,a=Object.keys(n).length;if(e?.[0]===a&&e[1]===s.event.request.length)return Function("data",e?.[2])({app:s,parseQuery:r,mapEarlyResponse:t,removeHostnameRegex:c,removeQueryRegex:u,removePathRegex:i,removeFragmentRegex:l});let o="";for(let e of Object.keys(n))o+=`,${e}: app.decorators.${e}`;let f=`const {
}`,h&&(y=h.transformSync(y));let q=Function("hooks",y);return q({handler:i,hooks:c,validator:l,handleError:u,utils:{createValidationError:o,mapResponse:s,mapEarlyResponse:t,mapErrorCode:d,parseQuery:r},meta:m,SCHEMA:m?a:void 0,DEFS:m?n:void 0})};export const composeGeneralHandler=s=>{let a=s.decorators,n=Object.keys(a).length;if(e?.[0]===n&&e[1]===s.event.request.length)return Function("data",e?.[2])({app:s,parseQuery:r,mapEarlyResponse:t,removeHostnameRegex:c,removeQueryRegex:u,removePathRegex:i,removeFragmentRegex:l});let o="";for(let e of Object.keys(a))o+=`,${e}: app.decorators.${e}`;let d=`const {
app,

@@ -158,10 +159,10 @@ app: { store, router, _s: _static },

const ctx = {
request,
store,
params: {},
query: {},
set: {
headers: {},
status: 200
}
},
params: {},
query: {},
request,
store
${o}

@@ -183,5 +184,5 @@ }

const url = request.url
const i = url.indexOf('?', 11)
const f = url.indexOf('#', 12)
const url = request.url,
i = url.indexOf('?', 11),
f = url.indexOf('#', 12)

@@ -194,5 +195,5 @@ let path;

if(f === -1) {
ctx.query = parseQuery(url.substring(i + 1), i)
ctx.query = { ...parseQuery(url.substring(i + 1), i) }
} else {
ctx.query = parseQuery(url.substring(i + 1, f), i)
ctx.query = { ...parseQuery(url.substring(i + 1, f), i) }
}

@@ -208,2 +209,3 @@ } else {

const handle = _static.get(request.method)?.get(path)
// const handle = _static.get(request.method + path)
if (handle) {

@@ -225,2 +227,2 @@ return handle(ctx)

}
}`;return h&&(f=h.transformSync(f)),e=[a,s.event.request.length,f],Function("data",f)({app:s,parseQuery:r,mapEarlyResponse:t,removeHostnameRegex:c,removeQueryRegex:u,removePathRegex:i,removeFragmentRegex:l})};
}`;return h&&(d=h.transformSync(d)),e=[n,s.event.request.length,d],Function("data",d)({app:s,parseQuery:r,mapEarlyResponse:t,removeHostnameRegex:c,removeQueryRegex:u,removePathRegex:i,removeFragmentRegex:l})};

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

import{Type as e}from"@sinclair/typebox";import{TypeSystem as t}from"@sinclair/typebox/system";try{t.Format("email",e=>/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e)),t.Format("uuid",e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)),t.Format("date",e=>!Number.isNaN(new Date(e).getTime())),t.Format("date-time",e=>!Number.isNaN(new Date(e).getTime()))}catch(e){}let i=e=>{if("string"==typeof e)switch(e.slice(-1)){case"k":return 1024*+e.substring(0,e.length-1);case"m":return 1048576*+e.substring(0,e.length-1);default:return+e}return e},r=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<i(e.minSize)||e.maxSize&&t.size>i(e.maxSize))return!1;if(e.extension){if("string"==typeof e.extension){if(!t.type.startsWith(e.extension))return!1}else{for(let i=0;i<e.extension.length;i++)if(t.type.startsWith(e.extension[i]))return!0;return!1}}return!0};export const ElysiaType={File:t.CreateType("File",r),Files:t.CreateType("Files",(e,t)=>{if(!Array.isArray(t)||e.minItems&&t.length<e.minItems||e.maxItems&&t.length>e.maxItems)return!1;for(let i=0;i<t.length;i++)if(!r(e,t[i]))return!1;return!0})};e.File=e=>ElysiaType.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"}),e.Files=e=>ElysiaType.Files({...e,default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});export{e as t};
import{Type as e}from"@sinclair/typebox";import{TypeSystem as t}from"@sinclair/typebox/system";try{t.Format("email",e=>/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e)),t.Format("uuid",e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)),t.Format("date",e=>!Number.isNaN(new Date(e).getTime())),t.Format("date-time",e=>!Number.isNaN(new Date(e).getTime()))}catch(e){}let i=e=>{if("string"==typeof e)switch(e.slice(-1)){case"k":return 1024*+e.slice(0,e.length-1);case"m":return 1048576*+e.slice(0,e.length-1);default:return+e}return e},r=(e,t)=>{if(!(t instanceof Blob)||e.minSize&&t.size<i(e.minSize)||e.maxSize&&t.size>i(e.maxSize))return!1;if(e.extension){if("string"==typeof e.extension){if(!t.type.startsWith(e.extension))return!1}else{for(let i=0;i<e.extension.length;i++)if(t.type.startsWith(e.extension[i]))return!0;return!1}}return!0};export const ElysiaType={File:t.CreateType("File",r),Files:t.CreateType("Files",(e,t)=>{if(!Array.isArray(t)||e.minItems&&t.length<e.minItems||e.maxItems&&t.length>e.maxItems)return!1;for(let i=0;i<t.length;i++)if(!r(e,t[i]))return!1;return!0})};e.File=e=>ElysiaType.File({default:"File",...e,extension:e?.type,type:"string",format:"binary"}),e.Files=e=>ElysiaType.Files({...e,default:"Files",extension:e?.type,type:"array",items:{...e,default:"Files",type:"string",format:"binary"}});export{e as t};

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

export const isNotEmpty=e=>{for(let s in e)return!0;return!1};let e=(e,s)=>{e.delete("Set-Cookie");for(let r=0;r<s.length;r++){let t=s[r].indexOf("=");e.append("Set-Cookie",`${s[r].substring(0,t)}=${s[r].substring(t+1)}`)}return e};export const mapEarlyResponse=(s,r)=>{if(isNotEmpty(r.headers)||200!==r.status||r.redirect)switch(r.redirect&&(r.headers.Location=r.redirect,r.status=302),r.headers["Set-Cookie"]&&Array.isArray(r.headers["Set-Cookie"])&&(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"])),typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s?.constructor.name){case"Error":return errorToResponse(s,r.headers);case"Response":for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"Blob":return new Response(s,{status:r.status,headers:r.headers});case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);if(void 0!==s)return s});default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers})}else switch(typeof s){case"string":return new Response(s);case"object":switch(s?.constructor?.name){case"Object":default:return Response.json(s);case"Response":return s;case"Error":return errorToResponse(s,r.headers);case"Blob":return new Response(s);case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);if(void 0!==s)return s})}case"function":if(s instanceof Blob)return new Response(s);return s;case"number":case"boolean":return new Response(s.toString())}};export const mapResponse=(s,r)=>{if(isNotEmpty(r.headers)||200!==r.status||r.redirect)switch(r.redirect&&(r.headers.Location=r.redirect,r.status=302),r.headers["Set-Cookie"]&&Array.isArray(r.headers["Set-Cookie"])&&(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"])),typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s?.constructor?.name){case"Error":return errorToResponse(s,r.headers);case"Response":for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"Blob":return new Response(s,{status:r.status,headers:r.headers});case"Promise":return s.then(e=>mapResponse(e,r));default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return s();case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers});case"undefined":return new Response("",{status:r.status,headers:r.headers});default:return new Response(s,{status:r.status,headers:r.headers})}else switch(typeof s){case"string":return new Response(s);case"object":switch(s?.constructor?.name){case"Object":default:return Response.json(s);case"Response":return s;case"Error":return errorToResponse(s,r.headers);case"Blob":return new Response(s);case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);return void 0!==s?s:new Response("")})}case"function":if(s instanceof Blob)return new Response(s);return s();case"number":case"boolean":return new Response(s.toString());case"undefined":return new Response("");default:return new Response(s)}};export const errorToResponse=(e,s)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:500,headers:s});
export const isNotEmpty=e=>{for(let s in e)return!0;return!1};let e=(e,s)=>{e.delete("Set-Cookie");for(let r=0;r<s.length;r++){let t=s[r].indexOf("=");e.append("Set-Cookie",`${s[r].slice(0,t)}=${s[r].slice(t+1)}`)}return e};export const mapEarlyResponse=(s,r)=>{if(isNotEmpty(r.headers)||200!==r.status||r.redirect)switch(r.redirect&&(r.headers.Location=r.redirect,r.status=302),r.headers["Set-Cookie"]&&Array.isArray(r.headers["Set-Cookie"])&&(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"])),typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s.constructor.name){case"Object":case void 0:return Response.json(s);case"Error":return errorToResponse(s,r.headers);case"Response":for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"Blob":return new Response(s,{status:r.status,headers:r.headers});case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);if(void 0!==s)return s});default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers})}else switch(typeof s){case"string":return new Response(s);case"object":switch(s.constructor?.name){case"Object":case void 0:default:return Response.json(s);case"Response":return s;case"Error":return errorToResponse(s,r.headers);case"Blob":return new Response(s);case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);if(void 0!==s)return s})}case"function":if(s instanceof Blob)return new Response(s);return s;case"number":case"boolean":return new Response(s.toString())}};export const mapResponse=(s,r)=>{if(isNotEmpty(r.headers)||200!==r.status||r.redirect)switch(r.redirect&&(r.headers.Location=r.redirect,r.status=302),r.headers["Set-Cookie"]&&Array.isArray(r.headers["Set-Cookie"])&&(r.headers=e(new Headers(r.headers),r.headers["Set-Cookie"])),typeof s){case"string":return new Response(s,{status:r.status,headers:r.headers});case"object":switch(s.constructor?.name){case"Object":case void 0:return Response.json(s);case"Error":return errorToResponse(s,r.headers);case"Response":for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"Blob":return new Response(s,{status:r.status,headers:r.headers});case"Promise":return s.then(e=>mapResponse(e,r));default:return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),{status:r.status,headers:r.headers})}case"function":if(s instanceof Blob)return new Response(s,{status:r.status,headers:r.headers});return s();case"number":case"boolean":return new Response(s.toString(),{status:r.status,headers:r.headers});case"undefined":return new Response("",{status:r.status,headers:r.headers});default:return new Response(s,{status:r.status,headers:r.headers})}else switch(typeof s){case"string":return new Response(s);case"object":switch(s.constructor?.name){case"Object":case void 0:default:return Response.json(s);case"Response":return s;case"Error":return errorToResponse(s,r.headers);case"Blob":return new Response(s);case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);return void 0!==s?s:new Response("")})}case"function":if(s instanceof Blob)return new Response(s);return s();case"number":case"boolean":return new Response(s.toString());case"undefined":return new Response("");default:return new Response(s)}};export const errorToResponse=(e,s)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:500,headers:s});

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

import{Kind as e}from"@sinclair/typebox";import t from"lodash.clonedeep";export const toOpenAPIPath=e=>e.split("/").map(e=>e.startsWith(":")?`{${e.substring(1,e.length)}}`:e).join("/");export const mapProperties=(e,t,r)=>{if(void 0===t)return[];if("string"==typeof t){if(t in r)t=r[t];else throw Error(`Can't find model ${t}`)}return Object.entries(t?.properties??[]).map(([r,o])=>({...o,in:e,name:r,type:o?.type,required:t.required?.includes(r)??!1}))};let r=(e,t)=>{let r={};for(let o of e)r[o]={schema:"string"==typeof t?{$ref:`#/components/schemas/${t}`}:{...t}};return r};export const registerSchemaPath=({schema:o,contentType:s=["application/json","multipart/form-data","text/plain"],path:i,method:n,hook:p,models:a})=>{p&&(p=t(p)),i=toOpenAPIPath(i);let c="string"==typeof s?[s]:s??["application/json"],l=p?.schema?.body,m=p?.schema?.params,f=p?.schema?.headers,h=p?.schema?.query,d=p?.schema?.response;if("object"==typeof d){if(e in d){let{type:e,properties:t,required:o,...s}=d;d={200:{...s,description:s.description,content:r(c,"object"===e||"array"===e?{type:e,properties:t,required:o}:d)}}}else Object.entries(d).forEach(([e,t])=>{if("string"==typeof t){let{type:o,properties:s,required:i,...n}=a[t];d[e]={...n,description:n.description,content:r(c,t)}}else{let{type:o,properties:s,required:i,...n}=t;d[e]={...n,description:n.description,content:r(c,{type:o,properties:s,required:i})}}})}else if("string"==typeof d){let{type:e,properties:t,required:o,...s}=a[d];d={200:{...s,content:r(c,d)}}}let y=[...mapProperties("header",f,a),...mapProperties("path",m,a),...mapProperties("query",h,a)];o[i]={...o[i]?o[i]:{},[n.toLowerCase()]:{...f||m||h||l?{parameters:y}:{},...d?{responses:d}:{},...p?.schema?.detail,...l?{requestBody:{content:r(c,"string"==typeof l?{$ref:`#/components/schemas/${l}`}:l)}}:null}}};
import{Kind as e}from"@sinclair/typebox";import t from"lodash.clonedeep";export const toOpenAPIPath=e=>e.split("/").map(e=>e.startsWith(":")?`{${e.slice(1,e.length)}}`:e).join("/");export const mapProperties=(e,t,r)=>{if(void 0===t)return[];if("string"==typeof t){if(t in r)t=r[t];else throw Error(`Can't find model ${t}`)}return Object.entries(t?.properties??[]).map(([r,o])=>({...o,in:e,name:r,type:o?.type,required:t.required?.includes(r)??!1}))};let r=(e,t)=>{let r={};for(let o of e)r[o]={schema:"string"==typeof t?{$ref:`#/components/schemas/${t}`}:{...t}};return r};export const registerSchemaPath=({schema:o,contentType:s=["application/json","multipart/form-data","text/plain"],path:i,method:n,hook:p,models:a})=>{p&&(p=t(p)),i=toOpenAPIPath(i);let c="string"==typeof s?[s]:s??["application/json"],l=p?.schema?.body,m=p?.schema?.params,f=p?.schema?.headers,h=p?.schema?.query,d=p?.schema?.response;if("object"==typeof d){if(e in d){let{type:e,properties:t,required:o,...s}=d;d={200:{...s,description:s.description,content:r(c,"object"===e||"array"===e?{type:e,properties:t,required:o}:d)}}}else Object.entries(d).forEach(([e,t])=>{if("string"==typeof t){let{type:o,properties:s,required:i,...n}=a[t];d[e]={...n,description:n.description,content:r(c,t)}}else{let{type:o,properties:s,required:i,...n}=t;d[e]={...n,description:n.description,content:r(c,{type:o,properties:s,required:i})}}})}else if("string"==typeof d){let{type:e,properties:t,required:o,...s}=a[d];d={200:{...s,content:r(c,d)}}}let y=[...mapProperties("header",f,a),...mapProperties("path",m,a),...mapProperties("query",h,a)];o[i]={...o[i]?o[i]:{},[n.toLowerCase()]:{...f||m||h||l?{parameters:y}:{},...d?{responses:d}:{},...p?.schema?.detail,...l?{requestBody:{content:r(c,"string"==typeof l?{$ref:`#/components/schemas/${l}`}:l)}}:null}}};
{
"name": "elysia",
"description": "Fast, and friendly Bun web framework",
"version": "0.5.0-exp-230427.1911",
"version": "0.5.0-exp-230427.2009",
"author": {

@@ -6,0 +6,0 @@ "name": "saltyAom",

@@ -282,5 +282,10 @@ import { Elysia } from '.'

},
meta,
SCHEMA,
DEFS
${
meta
? `
meta,
SCHEMA,
DEFS,`
: ''
}
} = hooks

@@ -311,4 +316,4 @@

meta,
SCHEMA,
DEFS
SCHEMA: meta ? SCHEMA : undefined,
DEFS: meta ? DEFS : undefined,
})

@@ -368,10 +373,10 @@ }

const ctx = {
request,
store,
params: {},
query: {},
set: {
headers: {},
status: 200
}
},
params: {},
query: {},
request,
store
${decoratorsLiteral}

@@ -397,5 +402,5 @@ }

const url = request.url
const i = url.indexOf('?', 11)
const f = url.indexOf('#', 12)
const url = request.url,
i = url.indexOf('?', 11),
f = url.indexOf('#', 12)

@@ -408,5 +413,5 @@ let path;

if(f === -1) {
ctx.query = parseQuery(url.substring(i + 1), i)
ctx.query = { ...parseQuery(url.substring(i + 1), i) }
} else {
ctx.query = parseQuery(url.substring(i + 1, f), i)
ctx.query = { ...parseQuery(url.substring(i + 1, f), i) }
}

@@ -422,2 +427,3 @@ } else {

const handle = _static.get(request.method)?.get(path)
// const handle = _static.get(request.method + path)
if (handle) {

@@ -424,0 +430,0 @@ return handle(ctx)

@@ -91,6 +91,6 @@ import { Type, type SchemaOptions } from '@sinclair/typebox'

case 'k':
return +size.substring(0, size.length - 1) * 1024
return +size.slice(0, size.length - 1) * 1024
case 'm':
return +size.substring(0, size.length - 1) * 1048576
return +size.slice(0, size.length - 1) * 1048576

@@ -97,0 +97,0 @@ default:

@@ -18,3 +18,3 @@ /* eslint-disable no-case-declarations */

'Set-Cookie',
`${setCookie[i].substring(0, index)}=${setCookie[i].substring(index + 1)}`
`${setCookie[i].slice(0, index)}=${setCookie[i].slice(index + 1)}`
)

@@ -55,3 +55,7 @@ }

case 'object':
switch (response?.constructor.name) {
switch (response!.constructor.name) {
case 'Object':
case undefined:
return Response.json(response)
case 'Error':

@@ -127,4 +131,5 @@ return errorToResponse(response as Error, set.headers)

case 'object':
switch (response?.constructor?.name) {
switch (response!.constructor?.name) {
case 'Object':
case undefined:
return Response.json(response)

@@ -198,3 +203,7 @@

case 'object':
switch (response?.constructor?.name) {
switch (response!.constructor?.name) {
case 'Object':
case undefined:
return Response.json(response)
case 'Error':

@@ -267,4 +276,5 @@ return errorToResponse(response as Error, set.headers)

case 'object':
switch (response?.constructor?.name) {
switch (response!.constructor?.name) {
case 'Object':
case undefined:
return Response.json(response)

@@ -271,0 +281,0 @@

@@ -10,3 +10,3 @@ import { Kind, type TSchema } from '@sinclair/typebox'

.split('/')
.map((x) => (x.startsWith(':') ? `{${x.substring(1, x.length)}}` : x))
.map((x) => (x.startsWith(':') ? `{${x.slice(1, x.length)}}` : x))
.join('/')

@@ -13,0 +13,0 @@

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