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

bunny-hono

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bunny-hono - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

2

dist/index.js

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

var N=Object.defineProperty,v=(n,t)=>{for(var e in t)N(n,e,{get:t[e],enumerable:!0})},w={};v(w,{http:()=>$,socketAddr:()=>P,tcp:()=>O});var O={};v(O,{bind:()=>E,isTcpListener:()=>B,toString:()=>C,unstable_local_addr:()=>D,unstable_new:()=>x});var k=n=>(n=n.toLowerCase(),n.includes("ios")?"iOS":n==="android"?"Android":n==="darwin"?"MacOS":n==="win32"?"Windows":n==="freebsd"?"FreeBSD":n==="openbsd"?"OpenBSD":n==="linux"?"Linux":n?`Other:${n}`:"Unknown"),S=()=>{if(typeof Bunny<"u")return{_tag:"_Platform",version:"0.11.2",name:"Unknown",runtime:"bunny",runtime_version:"unknown"};if(typeof Deno<"u"&&Deno.build!=null)return{_tag:"_Platform",version:"0.11.2",name:k(Deno.build.os),runtime:"deno",runtime_version:typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};let n=globalThis.process;return Object.prototype.toString.call(typeof n<"u"?n:0)==="[object process]"?{_tag:"_Platform",version:"0.11.2",name:k(n.platform),runtime:"node",runtime_version:n.version}:{_tag:"_Platform",version:"0.11.2",name:"Unknown",runtime:"unknown",runtime_version:"unknown"}},P={};v(P,{InvalidAddr:()=>Z,isV4:()=>A,v4:()=>i});var i={};v(i,{ip:()=>V,port:()=>I,tryFromString:()=>U});function H(n){return`${n[0]}.${n[1]}.${n[2]}.${n[3]}`}function T(n){let t=n.split(".").map(Number);return t.length!==4||t.some(e=>isNaN(e)||e<0||e>255)?new SyntaxError("Invalid IP address"):[t[0],t[1],t[2],t[3]]}function I(n){return n.port}function V(n){return n.ip}function U(n){let t=n.split(":");if(t.length!==2)return new SyntaxError("Invalid SocketAddrV4 address");let e=T(t[0]);if(e instanceof SyntaxError)return e;let r=Number(t[1]);return isNaN(r)||r<0||r>65535?new SyntaxError("Invalid Port"):{_tag:"SocketAddrV4",port:r,ip:e}}function A(n){return n._tag==="SocketAddrV4"}var F=Symbol("invalidAddr"),Z=class extends Error{_guard=F;constructor(n){super(n),this.name="InvalidAddr"}toString(){return`${this.name}: ${this.message}`}};function B(n){return n instanceof Object&&n._tag==="TcpListener"}function D(n){return n.addr}function C(n){switch(n.addr._tag){case"SocketAddrV4":return`${i.ip(n.addr).join(".")}:${i.port(n.addr)}`;case"NoAddr":return"No addr associated to this listener. You should be running in a controlled environment."}}function x(){switch(S().runtime){case"bunny":return{_tag:"TcpListener",addr:{_tag:"NoAddr"}};default:return{_tag:"TcpListener",addr:{_tag:"SocketAddrV4",port:8080,ip:[127,0,0,1]}}}}function E(n){return{_tag:"TcpListener",addr:n}}var $={};v($,{serve:()=>j,servePullZone:()=>W});var K={get:()=>{}},z=new Proxy({},K);function R(n){return n instanceof Response}function M(n){return n instanceof Request}function q(n){if(typeof n=="object"&&n!==null){let t=n.port;return t!==void 0&&typeof t=="number"&&n.hostname!==void 0}return!1}function j(n,t){let e,r;if(q(n)){let o=i.tryFromString(`${n.hostname}:${n.port}`);if(o instanceof Error)throw o;r=E(o),e=t}else B(n)?(e=t,r=n):(e=n,r=x());if(e===void 0)throw new Error("An issue happened.");switch(S().runtime){case"bunny":return Bunny.v1.serve(e),{};case"node":return(void 0)(r,e);case"deno":{let o=D(r);if(!A(o))throw new Error("An issue happened with the addr.");let c=i.port(o),h=H(i.ip(o));return Deno.serve({port:c,hostname:h},e),{}}case"unknown":return{}}}function W(n,t){let e,r={url:"https://bunny.net"};if(t&&(r=t),q(n)){let s=i.tryFromString(`${n.hostname}:${n.port}`);if(s instanceof Error)throw s;e=E(s)}else B(n)?e=n:(n&&(r=n),e=x());let o=[],c=[],h=S();switch(h.runtime){case"bunny":{Bunny.v1.registerMiddlewares({onOriginRequest:o,onOriginResponse:c});break}default:j(e,async s=>{let g=new URL(s.url),b=new URL(r.url);g.protocol=b.protocol,g.hostname=b.hostname,g.port=b.port;let y=new Request(g,s);for(let[f,m]of o.entries()){let u=await m({request:y});if(R(u))return u;M(u)&&(y=u)}let a=await fetch(y),d=new Headers;for(let[f,m]of a.headers.entries())d.set(f,m);let l;switch(h.runtime){case"node":{if(d.get("content-type")==="text/html"&&a.body!==null){let f=await a.text();d.delete("content-encoding"),l=new Response(f,{headers:d})}else l=new Response(a.body,{...a,headers:d});break}default:l=new Response(a.body,{...a,headers:d})}for(let[f,m]of c.entries()){let u=await m({request:y,response:l});R(u)&&(l=u)}return l})}let p={};return p.onOriginResponse=s=>(c.push(s),p),p.onOriginRequest=s=>(o.push(s),p),p}var _=globalThis?.process?.env??Deno.env.toObject(),L={port:8080,hostname:"127.0.0.1"};function G(n,t=L){w.http.serve(t,async e=>await n.fetch(e,{..._,request:e}))}function J(n,t=L,e){async function r(o){return await n.fetch(o.request,{..._,...o})}w.http.servePullZone(t,e).onOriginResponse(r)}function X(n){return n.env??_}export{X as env,J as middlewareHandler,G as standaloneHandler};
var N=Object.defineProperty,v=(n,t)=>{for(var e in t)N(n,e,{get:t[e],enumerable:!0})},w={};v(w,{http:()=>$,socketAddr:()=>P,tcp:()=>O});var O={};v(O,{bind:()=>E,isTcpListener:()=>B,toString:()=>C,unstable_local_addr:()=>D,unstable_new:()=>x});var k=n=>(n=n.toLowerCase(),n.includes("ios")?"iOS":n==="android"?"Android":n==="darwin"?"MacOS":n==="win32"?"Windows":n==="freebsd"?"FreeBSD":n==="openbsd"?"OpenBSD":n==="linux"?"Linux":n?`Other:${n}`:"Unknown"),S=()=>{if(typeof Bunny<"u")return{_tag:"_Platform",version:"0.11.2",name:"Unknown",runtime:"bunny",runtime_version:"unknown"};if(typeof Deno<"u"&&Deno.build!=null)return{_tag:"_Platform",version:"0.11.2",name:k(Deno.build.os),runtime:"deno",runtime_version:typeof Deno.version=="string"?Deno.version:Deno.version?.deno??"unknown"};let n=globalThis.process;return Object.prototype.toString.call(typeof n<"u"?n:0)==="[object process]"?{_tag:"_Platform",version:"0.11.2",name:k(n.platform),runtime:"node",runtime_version:n.version}:{_tag:"_Platform",version:"0.11.2",name:"Unknown",runtime:"unknown",runtime_version:"unknown"}},P={};v(P,{InvalidAddr:()=>Z,isV4:()=>A,v4:()=>i});var i={};v(i,{ip:()=>V,port:()=>I,tryFromString:()=>U});function T(n){return`${n[0]}.${n[1]}.${n[2]}.${n[3]}`}function H(n){let t=n.split(".").map(Number);return t.length!==4||t.some(e=>isNaN(e)||e<0||e>255)?new SyntaxError("Invalid IP address"):[t[0],t[1],t[2],t[3]]}function I(n){return n.port}function V(n){return n.ip}function U(n){let t=n.split(":");if(t.length!==2)return new SyntaxError("Invalid SocketAddrV4 address");let e=H(t[0]);if(e instanceof SyntaxError)return e;let r=Number(t[1]);return isNaN(r)||r<0||r>65535?new SyntaxError("Invalid Port"):{_tag:"SocketAddrV4",port:r,ip:e}}function A(n){return n._tag==="SocketAddrV4"}var F=Symbol("invalidAddr"),Z=class extends Error{_guard=F;constructor(n){super(n),this.name="InvalidAddr"}toString(){return`${this.name}: ${this.message}`}};function B(n){return n instanceof Object&&n._tag==="TcpListener"}function D(n){return n.addr}function C(n){switch(n.addr._tag){case"SocketAddrV4":return`${i.ip(n.addr).join(".")}:${i.port(n.addr)}`;case"NoAddr":return"No addr associated to this listener. You should be running in a controlled environment."}}function x(){switch(S().runtime){case"bunny":return{_tag:"TcpListener",addr:{_tag:"NoAddr"}};default:return{_tag:"TcpListener",addr:{_tag:"SocketAddrV4",port:8080,ip:[127,0,0,1]}}}}function E(n){return{_tag:"TcpListener",addr:n}}var $={};v($,{serve:()=>j,servePullZone:()=>W});var K={get:()=>{}},z=new Proxy({},K);function R(n){return n instanceof Response}function M(n){return n instanceof Request}function q(n){if(typeof n=="object"&&n!==null){let t=n.port;return t!==void 0&&typeof t=="number"&&n.hostname!==void 0}return!1}function j(n,t){let e,r;if(q(n)){let o=i.tryFromString(`${n.hostname}:${n.port}`);if(o instanceof Error)throw o;r=E(o),e=t}else B(n)?(e=t,r=n):(e=n,r=x());if(e===void 0)throw new Error("An issue happened.");switch(S().runtime){case"bunny":return Bunny.v1.serve(e),{};case"node":return(void 0)(r,e);case"deno":{let o=D(r);if(!A(o))throw new Error("An issue happened with the addr.");let c=i.port(o),h=T(i.ip(o));return Deno.serve({port:c,hostname:h},e),{}}case"unknown":return{}}}function W(n,t){let e,r={url:"https://bunny.net"};if(t&&(r=t),q(n)){let s=i.tryFromString(`${n.hostname}:${n.port}`);if(s instanceof Error)throw s;e=E(s)}else B(n)?e=n:(n&&(r=n),e=x());let o=[],c=[],h=S();switch(h.runtime){case"bunny":{Bunny.v1.registerMiddlewares({onOriginRequest:o,onOriginResponse:c});break}default:j(e,async s=>{let g=new URL(s.url),b=new URL(r.url);g.protocol=b.protocol,g.hostname=b.hostname,g.port=b.port;let y=new Request(g,s);for(let[f,m]of o.entries()){let u=await m({request:y});if(R(u))return u;M(u)&&(y=u)}let a=await fetch(y),d=new Headers;for(let[f,m]of a.headers.entries())d.set(f,m);let l;switch(h.runtime){case"node":{if(d.get("content-type")==="text/html"&&a.body!==null){let f=await a.text();d.delete("content-encoding"),l=new Response(f,{headers:d})}else l=new Response(a.body,{...a,headers:d});break}default:l=new Response(a.body,{...a,headers:d})}for(let[f,m]of c.entries()){let u=await m({request:y,response:l});R(u)&&(l=u)}return l})}let p={};return p.onOriginResponse=s=>(c.push(s),p),p.onOriginRequest=s=>(o.push(s),p),p}var _=globalThis?.process?.env??globalThis?.Deno?.env?.toObject(),L={port:8080,hostname:"127.0.0.1"};function G(n,t=L){w.http.serve(t,async e=>await n.fetch(e,{..._,request:e}))}function J(n,t=L,e){async function r(o){return await n.fetch(o.request,{..._,...o})}w.http.servePullZone(t,e).onOriginResponse(r)}function X(n){return n.env??_}export{X as env,J as middlewareHandler,G as standaloneHandler};
{
"name": "bunny-hono",
"version": "0.0.3",
"version": "0.0.4",
"private": false,

@@ -5,0 +5,0 @@ "type": "module",

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