Comparing version 0.5.7 to 0.5.8
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,r){for(var n in r)Object.defineProperty(e,n,{enumerable:!0,get:r[n]})}(exports,{isNotEmpty:function(){return e},mapEarlyResponse:function(){return n},mapResponse:function(){return s},mapCompactResponse:function(){return t},errorToResponse:function(){return o}});const e=e=>{for(let r in e)return!0;return!1},r=(e,r)=>{e.delete("Set-Cookie");for(let n=0;n<r.length;n++){let s=r[n].indexOf("=");e.append("Set-Cookie",`${r[n].slice(0,s)}=${r[n].slice(s+1)}`)}return e},n=(s,t)=>{if(e(t.headers)||200!==t.status||t.redirect)switch(t.redirect&&(t.headers.Location=t.redirect,t.status=302),t.headers["Set-Cookie"]&&Array.isArray(t.headers["Set-Cookie"])&&(t.headers=r(new Headers(t.headers),t.headers["Set-Cookie"])),s?.constructor?.name){case"String":case"Blob":return new Response(s,t);case"Object":case"Array":return Response.json(s,t);case void 0:if(!s)return;return Response.json(s,t);case"Response":for(let e in t.headers)s.headers.append(e,t.headers[e]);return s;case"Promise":return s.then(e=>{let r=n(e,t);if(void 0!==r)return r});case"Error":return o(s,t.headers);case"Function":return s();case"Number":case"Boolean":return new Response(s.toString(),t);default:return}else switch(s?.constructor?.name){case"String":case"Blob":return new Response(s);case"Object":case"Array":return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case void 0:if(!s)return new Response("");return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"Response":return s;case"Promise":return s.then(e=>{let r=n(e,t);if(void 0!==r)return r});case"Error":return o(s,t.headers);case"Function":return s();case"Number":case"Boolean":return new Response(s.toString());default:return}},s=(n,t)=>{if(e(t.headers)||200!==t.status||t.redirect)switch(t.redirect&&(t.headers.Location=t.redirect,t.status=302),t.headers["Set-Cookie"]&&Array.isArray(t.headers["Set-Cookie"])&&(t.headers=r(new Headers(t.headers),t.headers["Set-Cookie"])),n?.constructor?.name){case"String":case"Blob":return new Response(n,{status:t.status,headers:t.headers});case"Object":case"Array":return Response.json(n,t);case void 0:if(!n)return new Response("",t);return Response.json(n,t);case"Response":for(let e in t.headers)n.headers.append(e,t.headers[e]);return n;case"Error":return o(n,t.headers);case"Promise":return n.then(e=>s(e,t));case"Function":return n();case"Number":case"Boolean":return new Response(n.toString(),t);default:return new Response(n,t)}else switch(n?.constructor?.name){case"String":case"Blob":return new Response(n);case"Object":case"Array":return new Response(JSON.stringify(n),{headers:{"content-type":"application/json"}});case void 0:if(!n)return new Response("");return new Response(JSON.stringify(n),{headers:{"content-type":"application/json"}});case"Response":default:return n;case"Error":return o(n);case"Promise":return n.then(e=>{let r=s(e,t);return void 0!==r?r:new Response("")});case"Function":return n();case"Number":case"Boolean":return new Response(n.toString())}},t=e=>{switch(e.constructor?.name){case"String":case"Blob":return new Response(e);case"Object":case"Array":return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case void 0:if(!e)return new Response("");return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case"Response":default:return e;case"Error":return o(e);case"Promise":return e.then(e=>{let r=t(e);return void 0!==r?r:new Response("")});case"Function":return e();case"Number":case"Boolean":return new Response(e.toString())}},o=(e,r)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:500,headers:r}); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),function(e,n){for(var r in n)Object.defineProperty(e,r,{enumerable:!0,get:n[r]})}(exports,{isNotEmpty:function(){return e},mapEarlyResponse:function(){return r},mapResponse:function(){return s},mapCompactResponse:function(){return t},errorToResponse:function(){return o}});const e=e=>{for(let n in e)return!0;return!1},n=(e,n)=>{e.delete("Set-Cookie");for(let r=0;r<n.length;r++){let s=n[r].indexOf("=");e.append("Set-Cookie",`${n[r].slice(0,s)}=${n[r].slice(s+1)}`)}return e},r=(s,t)=>{if(e(t.headers)||200!==t.status||t.redirect)switch(t.redirect&&(t.headers.Location=t.redirect,t.status=302),t.headers["Set-Cookie"]&&Array.isArray(t.headers["Set-Cookie"])&&(t.headers=n(new Headers(t.headers),t.headers["Set-Cookie"])),s?.constructor?.name){case"String":case"Blob":return new Response(s,t);case"Object":case"Array":return Response.json(s,t);case void 0:if(!s)return;return Response.json(s,t);case"Response":for(let e in t.headers)s.headers.append(e,t.headers[e]);return s;case"Promise":return s.then(e=>{let n=r(e,t);if(void 0!==n)return n});case"Error":return o(s,t.headers);case"Function":return s();case"Number":case"Boolean":return new Response(s.toString(),t);default:if(s instanceof Response)return s;let a=JSON.stringify(s);if(123===a.charCodeAt(0))return t.headers["Content-Type"]||(t.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),t);return new Response(a,t)}else switch(s?.constructor?.name){case"String":case"Blob":return new Response(s);case"Object":case"Array":return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case void 0:if(!s)return new Response("");return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"Response":return s;case"Promise":return s.then(e=>{let n=r(e,t);if(void 0!==n)return n});case"Error":return o(s,t.headers);case"Function":return s();case"Number":case"Boolean":return new Response(s.toString());default:if(s instanceof Response)return s;let i=JSON.stringify(s);if(123===i.charCodeAt(0))return new Response(JSON.stringify(s),{headers:{"Content-Type":"application/json"}});return new Response(i)}},s=(r,t)=>{if(e(t.headers)||200!==t.status||t.redirect)switch(t.redirect&&(t.headers.Location=t.redirect,t.status=302),t.headers["Set-Cookie"]&&Array.isArray(t.headers["Set-Cookie"])&&(t.headers=n(new Headers(t.headers),t.headers["Set-Cookie"])),r?.constructor?.name){case"String":case"Blob":return new Response(r,{status:t.status,headers:t.headers});case"Object":case"Array":return Response.json(r,t);case void 0:if(!r)return new Response("",t);return Response.json(r,t);case"Response":for(let e in t.headers)r.headers.append(e,t.headers[e]);return r;case"Error":return o(r,t.headers);case"Promise":return r.then(e=>s(e,t));case"Function":return r();case"Number":case"Boolean":return new Response(r.toString(),t);default:if(r instanceof Response)return r;let a=JSON.stringify(r);if(123===a.charCodeAt(0))return t.headers["Content-Type"]||(t.headers["Content-Type"]="application/json"),new Response(JSON.stringify(r),t);return new Response(a,t)}else switch(r?.constructor?.name){case"String":case"Blob":return new Response(r);case"Object":case"Array":return new Response(JSON.stringify(r),{headers:{"content-type":"application/json"}});case void 0:if(!r)return new Response("");return new Response(JSON.stringify(r),{headers:{"content-type":"application/json"}});case"Response":return r;case"Error":return o(r);case"Promise":return r.then(e=>{let n=s(e,t);return void 0!==n?n:new Response("")});case"Function":return r();case"Number":case"Boolean":return new Response(r.toString());default:if(r instanceof Response)return r;let i=JSON.stringify(r);if(123===i.charCodeAt(0))return new Response(JSON.stringify(r),{headers:{"Content-Type":"application/json"}});return new Response(i)}},t=e=>{switch(e.constructor?.name){case"String":case"Blob":return new Response(e);case"Object":case"Array":return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case void 0:if(!e)return new Response("");return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case"Response":return e;case"Error":return o(e);case"Promise":return e.then(e=>{let n=t(e);return void 0!==n?n:new Response("")});case"Function":return e();case"Number":case"Boolean":return new Response(e.toString());default:if(e instanceof Response)return e;let n=JSON.stringify(e);if(123===n.charCodeAt(0))return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}});return new Response(n)}},o=(e,n)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:500,headers:n}); |
@@ -1,1 +0,1 @@ | ||
export const isNotEmpty=e=>{for(let r in e)return!0;return!1};let e=(e,r)=>{e.delete("Set-Cookie");for(let s=0;s<r.length;s++){let n=r[s].indexOf("=");e.append("Set-Cookie",`${r[s].slice(0,n)}=${r[s].slice(n+1)}`)}return e};export const mapEarlyResponse=(r,s)=>{if(isNotEmpty(s.headers)||200!==s.status||s.redirect)switch(s.redirect&&(s.headers.Location=s.redirect,s.status=302),s.headers["Set-Cookie"]&&Array.isArray(s.headers["Set-Cookie"])&&(s.headers=e(new Headers(s.headers),s.headers["Set-Cookie"])),r?.constructor?.name){case"String":case"Blob":return new Response(r,s);case"Object":case"Array":return Response.json(r,s);case void 0:if(!r)return;return Response.json(r,s);case"Response":for(let e in s.headers)r.headers.append(e,s.headers[e]);return r;case"Promise":return r.then(e=>{let r=mapEarlyResponse(e,s);if(void 0!==r)return r});case"Error":return errorToResponse(r,s.headers);case"Function":return r();case"Number":case"Boolean":return new Response(r.toString(),s);default:return}else switch(r?.constructor?.name){case"String":case"Blob":return new Response(r);case"Object":case"Array":return new Response(JSON.stringify(r),{headers:{"content-type":"application/json"}});case void 0:if(!r)return new Response("");return new Response(JSON.stringify(r),{headers:{"content-type":"application/json"}});case"Response":return r;case"Promise":return r.then(e=>{let r=mapEarlyResponse(e,s);if(void 0!==r)return r});case"Error":return errorToResponse(r,s.headers);case"Function":return r();case"Number":case"Boolean":return new Response(r.toString());default:return}};export const mapResponse=(r,s)=>{if(isNotEmpty(s.headers)||200!==s.status||s.redirect)switch(s.redirect&&(s.headers.Location=s.redirect,s.status=302),s.headers["Set-Cookie"]&&Array.isArray(s.headers["Set-Cookie"])&&(s.headers=e(new Headers(s.headers),s.headers["Set-Cookie"])),r?.constructor?.name){case"String":case"Blob":return new Response(r,{status:s.status,headers:s.headers});case"Object":case"Array":return Response.json(r,s);case void 0:if(!r)return new Response("",s);return Response.json(r,s);case"Response":for(let e in s.headers)r.headers.append(e,s.headers[e]);return r;case"Error":return errorToResponse(r,s.headers);case"Promise":return r.then(e=>mapResponse(e,s));case"Function":return r();case"Number":case"Boolean":return new Response(r.toString(),s);default:return new Response(r,s)}else switch(r?.constructor?.name){case"String":case"Blob":return new Response(r);case"Object":case"Array":return new Response(JSON.stringify(r),{headers:{"content-type":"application/json"}});case void 0:if(!r)return new Response("");return new Response(JSON.stringify(r),{headers:{"content-type":"application/json"}});case"Response":default:return r;case"Error":return errorToResponse(r);case"Promise":return r.then(e=>{let r=mapResponse(e,s);return void 0!==r?r:new Response("")});case"Function":return r();case"Number":case"Boolean":return new Response(r.toString())}};export const mapCompactResponse=e=>{switch(e.constructor?.name){case"String":case"Blob":return new Response(e);case"Object":case"Array":return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case void 0:if(!e)return new Response("");return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case"Response":default:return e;case"Error":return errorToResponse(e);case"Promise":return e.then(e=>{let r=mapCompactResponse(e);return void 0!==r?r:new Response("")});case"Function":return e();case"Number":case"Boolean":return new Response(e.toString())}};export const errorToResponse=(e,r)=>new Response(JSON.stringify({name:e?.name,message:e?.message,cause:e?.cause}),{status:500,headers:r}); | ||
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 n=s[r].indexOf("=");e.append("Set-Cookie",`${s[r].slice(0,n)}=${s[r].slice(n+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"])),s?.constructor?.name){case"String":case"Blob":return new Response(s,r);case"Object":case"Array":return Response.json(s,r);case void 0:if(!s)return;return Response.json(s,r);case"Response":for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);if(void 0!==s)return s});case"Error":return errorToResponse(s,r.headers);case"Function":return s();case"Number":case"Boolean":return new Response(s.toString(),r);default:if(s instanceof Response)return s;let n=JSON.stringify(s);if(123===n.charCodeAt(0))return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),r);return new Response(n,r)}else switch(s?.constructor?.name){case"String":case"Blob":return new Response(s);case"Object":case"Array":return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case void 0:if(!s)return new Response("");return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"Response":return s;case"Promise":return s.then(e=>{let s=mapEarlyResponse(e,r);if(void 0!==s)return s});case"Error":return errorToResponse(s,r.headers);case"Function":return s();case"Number":case"Boolean":return new Response(s.toString());default:if(s instanceof Response)return s;let t=JSON.stringify(s);if(123===t.charCodeAt(0))return new Response(JSON.stringify(s),{headers:{"Content-Type":"application/json"}});return new Response(t)}};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"])),s?.constructor?.name){case"String":case"Blob":return new Response(s,{status:r.status,headers:r.headers});case"Object":case"Array":return Response.json(s,r);case void 0:if(!s)return new Response("",r);return Response.json(s,r);case"Response":for(let e in r.headers)s.headers.append(e,r.headers[e]);return s;case"Error":return errorToResponse(s,r.headers);case"Promise":return s.then(e=>mapResponse(e,r));case"Function":return s();case"Number":case"Boolean":return new Response(s.toString(),r);default:if(s instanceof Response)return s;let n=JSON.stringify(s);if(123===n.charCodeAt(0))return r.headers["Content-Type"]||(r.headers["Content-Type"]="application/json"),new Response(JSON.stringify(s),r);return new Response(n,r)}else switch(s?.constructor?.name){case"String":case"Blob":return new Response(s);case"Object":case"Array":return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case void 0:if(!s)return new Response("");return new Response(JSON.stringify(s),{headers:{"content-type":"application/json"}});case"Response":return s;case"Error":return errorToResponse(s);case"Promise":return s.then(e=>{let s=mapResponse(e,r);return void 0!==s?s:new Response("")});case"Function":return s();case"Number":case"Boolean":return new Response(s.toString());default:if(s instanceof Response)return s;let t=JSON.stringify(s);if(123===t.charCodeAt(0))return new Response(JSON.stringify(s),{headers:{"Content-Type":"application/json"}});return new Response(t)}};export const mapCompactResponse=e=>{switch(e.constructor?.name){case"String":case"Blob":return new Response(e);case"Object":case"Array":return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case void 0:if(!e)return new Response("");return new Response(JSON.stringify(e),{headers:{"content-type":"application/json"}});case"Response":return e;case"Error":return errorToResponse(e);case"Promise":return e.then(e=>{let s=mapCompactResponse(e);return void 0!==s?s:new Response("")});case"Function":return e();case"Number":case"Boolean":return new Response(e.toString());default:if(e instanceof Response)return e;let s=JSON.stringify(e);if(123===s.charCodeAt(0))return new Response(JSON.stringify(e),{headers:{"Content-Type":"application/json"}});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}); |
{ | ||
"name": "elysia", | ||
"description": "Fast, and friendly Bun web framework", | ||
"version": "0.5.7", | ||
"version": "0.5.8", | ||
"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
202112