Comparing version 0.5.6 to 0.5.7
@@ -17,3 +17,3 @@ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,r){for(var t in r)Object.defineProperty(e,t,{enumerable:!0,get:r[t]})}(exports,{hasReturn:function(){return l},isFnUse:function(){return u},findElysiaMeta:function(){return f},composeHandler:function(){return d},composeGeneralHandler:function(){return p},composeErrorHandler:function(){return y}});const e=require("fast-querystring"),r=require("./handler"),t=require("./utils"),n=require("./error"),s="AsyncFunction",o=e=>e.constructor.name===s,a=new Headers,c=RegExp(" (\\w+) = context","g"),l=e=>{let r=e.indexOf(")");return 61===e.charCodeAt(r+2)&&123!==e.charCodeAt(r+5)||e.includes("return")},i=e=>({composeValidation:(r,t=`c.${r}`)=>e?`throw new ValidationError( | ||
${r} | ||
).toResponse(c.set.headers)`}),u=(e,r)=>{let t=r.slice(r.indexOf("(")+1,r.indexOf(")"));if(""===t)return!1;if(123===t.charCodeAt(0))return!!(t.includes(`{ ${e}`)||t.includes(`, ${e}`));if(r.match(RegExp(`${t}(.${e}|\\["${e}"\\])`)))return!0;let n=[t];for(let e of r.matchAll(c))n.push(e[1]);let s=RegExp(`{.*?} = (${n.join("|")})`,"g");for(let[t]of r.matchAll(s))if(t.includes(`{ ${e}`)||t.includes(`, ${e}`))return!0;return!1},f=(e,r,t=[],n="")=>{if("object"===r.type){let s=r.properties;for(let r in s){let o=s[r],a=n?n+"."+r:r;if("object"===o.type){f(e,o,t,a);continue}if(o.anyOf){for(let r of o.anyOf)f(e,r,t,a);continue}o.elysiaMeta===e&&t.push(a)}return 0===t.length?null:t}return r?.elysiaMeta===e?(n&&t.push(n),"root"):null},d=({method:c,hooks:d,validator:p,handler:y,handleError:$,meta:h,onRequest:m,config:b})=>{let E=b.forceErrorEncapsulation||d.error.length>0||void 0===Bun,{composeValidation:q,composeResponseValidation:g}=i(E),w=E?"try {\n":"",x="string"==typeof d.type,k=p||"GET"!==c?[y,...d.transform,...d.beforeHandle,...d.afterHandle].map(e=>e.toString()):[],H="GET"!==c&&(p.body||x||k.some(e=>u("body",e))),R=p.headers||k.some(e=>u("headers",e));R&&(w+=a.toJSON?`c.headers = c.request.headers.toJSON() | ||
).toResponse(c.set.headers)`}),u=(e,r)=>{let t=r.slice(r.indexOf("(")+1,r.indexOf(")"));if(""===t)return!1;if(123===t.charCodeAt(0))return!!(t.includes(`{ ${e}`)||t.includes(`, ${e}`));if(r.match(RegExp(`${t}(.${e}|\\["${e}"\\])`)))return!0;let n=[t];for(let e of r.matchAll(c))n.push(e[1]);let s=RegExp(`{.*?} = (${n.join("|")})`,"g");for(let[t]of r.matchAll(s))if(t.includes(`{ ${e}`)||t.includes(`, ${e}`))return!0;return!1},f=(e,r,t=[],n="")=>{if("object"===r.type){let s=r.properties;for(let r in s){let o=s[r],a=n?n+"."+r:r;if("object"===o.type){f(e,o,t,a);continue}if(o.anyOf){for(let r of o.anyOf)f(e,r,t,a);continue}o.elysiaMeta===e&&t.push(a)}return 0===t.length?null:t}return r?.elysiaMeta===e?(n&&t.push(n),"root"):null},d=({method:c,hooks:d,validator:p,handler:y,handleError:$,meta:h,onRequest:m,config:b})=>{let E=b.forceErrorEncapsulation||d.error.length>0||"undefined"==typeof Bun,{composeValidation:q,composeResponseValidation:g}=i(E),w=E?"try {\n":"",x="string"==typeof d.type,k=p||"GET"!==c?[y,...d.transform,...d.beforeHandle,...d.afterHandle].map(e=>e.toString()):[],H="GET"!==c&&(p.body||x||k.some(e=>u("body",e))),R=p.headers||k.some(e=>u("headers",e));R&&(w+=a.toJSON?`c.headers = c.request.headers.toJSON() | ||
`:`c.headers = {} | ||
@@ -20,0 +20,0 @@ for (const key of c.request.headers.keys()) |
@@ -17,3 +17,3 @@ import{parse as e}from"fast-querystring";import{mapEarlyResponse as r,mapResponse as t,mapCompactResponse as s}from"./handler";import{SCHEMA as n,DEFS as o}from"./utils";import{ParseError as a,NotFoundError as c,ValidationError as l,InternalServerError as i}from"./error";let f="AsyncFunction",u=e=>e.constructor.name===f,d=new Headers,p=RegExp(" (\\w+) = context","g");export const hasReturn=e=>{let r=e.indexOf(")");return 61===e.charCodeAt(r+2)&&123!==e.charCodeAt(r+5)||e.includes("return")};let y=e=>({composeValidation:(r,t=`c.${r}`)=>e?`throw new ValidationError( | ||
${r} | ||
).toResponse(c.set.headers)`});export const isFnUse=(e,r)=>{let t=r.slice(r.indexOf("(")+1,r.indexOf(")"));if(""===t)return!1;if(123===t.charCodeAt(0))return!!(t.includes(`{ ${e}`)||t.includes(`, ${e}`));if(r.match(RegExp(`${t}(.${e}|\\["${e}"\\])`)))return!0;let s=[t];for(let e of r.matchAll(p))s.push(e[1]);let n=RegExp(`{.*?} = (${s.join("|")})`,"g");for(let[t]of r.matchAll(n))if(t.includes(`{ ${e}`)||t.includes(`, ${e}`))return!0;return!1};export const findElysiaMeta=(e,r,t=[],s="")=>{if("object"===r.type){let n=r.properties;for(let r in n){let o=n[r],a=s?s+"."+r:r;if("object"===o.type){findElysiaMeta(e,o,t,a);continue}if(o.anyOf){for(let r of o.anyOf)findElysiaMeta(e,r,t,a);continue}o.elysiaMeta===e&&t.push(a)}return 0===t.length?null:t}return r?.elysiaMeta===e?(s&&t.push(s),"root"):null};export const composeHandler=({method:p,hooks:h,validator:$,handler:m,handleError:b,meta:q,onRequest:E,config:g})=>{let x=g.forceErrorEncapsulation||h.error.length>0||void 0===Bun,{composeValidation:w,composeResponseValidation:k}=y(x),H=x?"try {\n":"",R="string"==typeof h.type,v=$||"GET"!==p?[m,...h.transform,...h.beforeHandle,...h.afterHandle].map(e=>e.toString()):[],O="GET"!==p&&($.body||R||v.some(e=>isFnUse("body",e))),S=$.headers||v.some(e=>isFnUse("headers",e));S&&(H+=d.toJSON?`c.headers = c.request.headers.toJSON() | ||
).toResponse(c.set.headers)`});export const isFnUse=(e,r)=>{let t=r.slice(r.indexOf("(")+1,r.indexOf(")"));if(""===t)return!1;if(123===t.charCodeAt(0))return!!(t.includes(`{ ${e}`)||t.includes(`, ${e}`));if(r.match(RegExp(`${t}(.${e}|\\["${e}"\\])`)))return!0;let s=[t];for(let e of r.matchAll(p))s.push(e[1]);let n=RegExp(`{.*?} = (${s.join("|")})`,"g");for(let[t]of r.matchAll(n))if(t.includes(`{ ${e}`)||t.includes(`, ${e}`))return!0;return!1};export const findElysiaMeta=(e,r,t=[],s="")=>{if("object"===r.type){let n=r.properties;for(let r in n){let o=n[r],a=s?s+"."+r:r;if("object"===o.type){findElysiaMeta(e,o,t,a);continue}if(o.anyOf){for(let r of o.anyOf)findElysiaMeta(e,r,t,a);continue}o.elysiaMeta===e&&t.push(a)}return 0===t.length?null:t}return r?.elysiaMeta===e?(s&&t.push(s),"root"):null};export const composeHandler=({method:p,hooks:h,validator:$,handler:m,handleError:b,meta:q,onRequest:E,config:g})=>{let x=g.forceErrorEncapsulation||h.error.length>0||"undefined"==typeof Bun,{composeValidation:w,composeResponseValidation:k}=y(x),H=x?"try {\n":"",R="string"==typeof h.type,v=$||"GET"!==p?[m,...h.transform,...h.beforeHandle,...h.afterHandle].map(e=>e.toString()):[],O="GET"!==p&&($.body||R||v.some(e=>isFnUse("body",e))),S=$.headers||v.some(e=>isFnUse("headers",e));S&&(H+=d.toJSON?`c.headers = c.request.headers.toJSON() | ||
`:`c.headers = {} | ||
@@ -20,0 +20,0 @@ for (const key of c.request.headers.keys()) |
{ | ||
"name": "elysia", | ||
"description": "Fast, and friendly Bun web framework", | ||
"version": "0.5.6", | ||
"version": "0.5.7", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "saltyAom", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
200152