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

rjweb-server

Package Overview
Dependencies
Maintainers
1
Versions
375
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rjweb-server - npm Package Compare versions

Comparing version 2.1.2 to 2.1.3

6

lib/cjs/classes/routeList.js

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

var N=Object.create;var a=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var L=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),M=(s,e)=>{for(var t in e)a(s,t,{get:e[t],enumerable:!0})},x=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of V(e))!C.call(s,i)&&i!==t&&a(s,i,{get:()=>e[i],enumerable:!(r=H(e,i))||r.enumerable});return s};var p=(s,e,t)=>(t=s!=null?N(q(s)):{},x(e||!s||!s.__esModule?a(t,"default",{value:s,enumerable:!0}):t,s)),j=s=>x(a({},"__esModule",{value:!0}),s);var P=L((G,E)=>{E.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});var w={};M(w,{default:()=>f,pathParser:()=>h});module.exports=j(w);var u=p(require("fs")),d=(s,e)=>(e=e||[],u.readdirSync(s).forEach(r=>{if(u.statSync(s+"/"+r).isDirectory())e=d(s+"/"+r,e);else{let i=s+"/"+r;e.push(i)}}),e),I=(s,e,t)=>(t=t||[],t=d(s,t).filter(r=>r.endsWith(e)),t);var c=p(P()),S=p(require("path")),W=p(require("fs")),h=s=>(s=s.replace(/\/{2,}/g,"/"),s.endsWith("/")?s.slice(0,-1):s.startsWith("/")?s:`/${s}`),f=class{constructor(e,t){e=e!=null?e:[],t=t!=null?t:[],this.routes=e,this.events=t}event(e,t){return this.events.some(r=>r.event===e)?!1:this.events.push({event:e,code:t})}set(e,t,r){if(t=h(t),!c.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${c.default.join(", ")}`);return this.routes.some(i=>i.method===e&&i.path===t)?!1:this.routes.push({method:e,path:t,pathArray:t.split("/"),code:r,data:{addTypes:!1}})}static(e,t,r){var y,g,$;e=h(e);let i=(y=r==null?void 0:r.preload)!=null?y:!1,n=(g=r==null?void 0:r.remHTML)!=null?g:!1,b=($=r==null?void 0:r.addTypes)!=null?$:!0,T=[];for(let m of d(t)){let l=m.replace(t,"").replace("/",""),o=e+t.replace(l,"").replace(t,"").slice(0,-1);o.startsWith(".")&&(o=o.slice(-1)),n&&l==="index.html"?l="":n&&l.endsWith(".html")?l=l.slice(0,-5):n&&l.endsWith(".htm")&&(l=l.slice(0,-4));let v=`${o}/${l}`.endsWith("/")?`${o}`:`${o}`=="/"?`/${l}`:`${o}/${l}`,A=this.routes.push({method:"STATIC",path:v,pathArray:v.split("/"),code:async()=>null,data:{addTypes:b,file:m}});i&&(this.routes[A].data.content=W.readFileSync(m)),T.push(A)}return T}load(e){let t=I(e,".js"),r=[];for(let i of t){let n=require(S.resolve(i));if(!(!("path"in n)||!("method"in n)||!("code"in n))){if(!c.default.includes(n.type))throw TypeError(`No Valid Request Type: ${n.method}
Possible Values: ${c.default.join(", ")}`);r.push(this.routes.push({method:n.method,path:n.path,pathArray:n.path.split("/"),code:n.code,data:{addTypes:!1}}))}}return r}list(){return{routes:this.routes,events:this.events}}};0&&(module.exports={pathParser});
var N=Object.create;var a=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty;var L=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),M=(s,e)=>{for(var t in e)a(s,t,{get:e[t],enumerable:!0})},x=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of V(e))!C.call(s,i)&&i!==t&&a(s,i,{get:()=>e[i],enumerable:!(r=H(e,i))||r.enumerable});return s};var d=(s,e,t)=>(t=s!=null?N(q(s)):{},x(e||!s||!s.__esModule?a(t,"default",{value:s,enumerable:!0}):t,s)),j=s=>x(a({},"__esModule",{value:!0}),s);var P=L((G,I)=>{I.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});var w={};M(w,{default:()=>f,pathParser:()=>h});module.exports=j(w);var u=d(require("fs")),p=(s,e)=>(e=e||[],u.readdirSync(s).forEach(r=>{if(u.statSync(s+"/"+r).isDirectory())e=p(s+"/"+r,e);else{let i=s+"/"+r;e.push(i)}}),e),E=(s,e,t)=>(t=t||[],t=p(s,t).filter(r=>r.endsWith(e)),t);var c=d(P()),S=d(require("path")),W=d(require("fs")),h=s=>(s=s.replace(/\/{2,}/g,"/"),s.endsWith("/")?s.slice(0,-1):s.startsWith("/")?s:`/${s}`),f=class{constructor(e,t){e=e!=null?e:[],t=t!=null?t:[],this.routes=e,this.events=t}event(e,t){return this.events.some(r=>r.event===e)?!1:this.events.push({event:e,code:t})-1}set(e,t,r){if(t=h(t),!c.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${c.default.join(", ")}`);return this.routes.some(i=>i.method===e&&i.path===t)?!1:this.routes.push({method:e,path:t,pathArray:t.split("/"),code:r,data:{addTypes:!1}})-1}static(e,t,r){var y,g,$;e=h(e);let i=(y=r==null?void 0:r.preload)!=null?y:!1,n=(g=r==null?void 0:r.remHTML)!=null?g:!1,b=($=r==null?void 0:r.addTypes)!=null?$:!0,T=[];for(let m of p(t)){let o=m.replace(t,"").replace("/",""),l=e+t.replace(o,"").replace(t,"").slice(0,-1);l.startsWith(".")&&(l=l.slice(-1)),n&&o==="index.html"?o="":n&&o.endsWith(".html")?o=o.slice(0,-5):n&&o.endsWith(".htm")&&(o=o.slice(0,-4));let v=`${l}/${o}`.endsWith("/")?`${l}`:`${l}`=="/"?`/${o}`:`${l}/${o}`,A=this.routes.push({method:"STATIC",path:v,pathArray:v.split("/"),code:async()=>{},data:{addTypes:b,file:m}});i&&(this.routes[A-1].data.content=W.readFileSync(m)),T.push(A-1)}return T}load(e){let t=E(e,".js"),r=[];for(let i of t){let n=require(S.resolve(i));if(!(!("path"in n)||!("method"in n)||!("code"in n))){if(!c.default.includes(n.method))throw TypeError(`No Valid Request Type: ${n.method}
Possible Values: ${c.default.join(", ")}`);r.push(this.routes.push({method:n.method,path:n.path,pathArray:n.path.split("/"),code:n.code,data:{addTypes:!1}}))-1}}return r}list(){return{routes:this.routes,events:this.events}}};0&&(module.exports={pathParser});

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

var ue=Object.create;var q=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var ye=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var we=(r,e,a,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of he(e))!pe.call(r,l)&&l!==a&&q(r,l,{get:()=>e[l],enumerable:!(c=fe(e,l))||c.enumerable});return r};var E=(r,e,a)=>(a=r!=null?ue(me(r)):{},we(e||!r||!r.__esModule?q(a,"default",{value:r,enumerable:!0}):a,r));var j=ye((Te,te)=>{te.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});var N=E(require("fs")),$=(r,e)=>(e=e||[],N.readdirSync(r).forEach(c=>{if(N.statSync(r+"/"+c).isDirectory())e=$(r+"/"+c,e);else{let l=r+"/"+c;e.push(l)}}),e),ee=(r,e,a)=>(a=a||[],a=$(r,a).filter(c=>c.endsWith(e)),a);var L=E(j()),se=E(require("path")),ae=E(require("fs")),re=r=>(r=r.replace(/\/{2,}/g,"/"),r.endsWith("/")?r.slice(0,-1):r.startsWith("/")?r:`/${r}`),W=class{constructor(e,a){e=e!=null?e:[],a=a!=null?a:[],this.routes=e,this.events=a}event(e,a){return this.events.some(c=>c.event===e)?!1:this.events.push({event:e,code:a})}set(e,a,c){if(a=re(a),!L.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${L.default.join(", ")}`);return this.routes.some(l=>l.method===e&&l.path===a)?!1:this.routes.push({method:e,path:a,pathArray:a.split("/"),code:c,data:{addTypes:!1}})}static(e,a,c){var H,I,b;e=re(e);let l=(H=c==null?void 0:c.preload)!=null?H:!1,f=(I=c==null?void 0:c.remHTML)!=null?I:!1,O=(b=c==null?void 0:c.addTypes)!=null?b:!0,w=[];for(let T of $(a)){let h=T.replace(a,"").replace("/",""),g=e+a.replace(h,"").replace(a,"").slice(0,-1);g.startsWith(".")&&(g=g.slice(-1)),f&&h==="index.html"?h="":f&&h.endsWith(".html")?h=h.slice(0,-5):f&&h.endsWith(".htm")&&(h=h.slice(0,-4));let A=`${g}/${h}`.endsWith("/")?`${g}`:`${g}`=="/"?`/${h}`:`${g}/${h}`,C=this.routes.push({method:"STATIC",path:A,pathArray:A.split("/"),code:async()=>null,data:{addTypes:O,file:T}});l&&(this.routes[C].data.content=ae.readFileSync(T)),w.push(C)}return w}load(e){let a=ee(e,".js"),c=[];for(let l of a){let f=require(se.resolve(l));if(!(!("path"in f)||!("method"in f)||!("code"in f))){if(!L.default.includes(f.type))throw TypeError(`No Valid Request Type: ${f.method}
Possible Values: ${L.default.join(", ")}`);c.push(this.routes.push({method:f.method,path:f.path,pathArray:f.path.split("/"),code:f.code,data:{addTypes:!1}}))}}return c}list(){return{routes:this.routes,events:this.events}}};var ne=(w=>(w.options="OPTIONS",w.delete="DELETE",w.patch="PATCH",w.post="POST",w.put="PUT",w.get="GET",w.static="STATIC",w))(ne||{}),ie=ne;var oe=E(j()),ce=E(require("path")),le=E(require("http")),de=E(require("url")),M=E(require("fs"));module.exports={routeList:W,types:ie,async start(r){var h,g,A,C,D,V,G,J,X,F,z;let e=(g=(h=r==null?void 0:r.routes)==null?void 0:h.list().routes)!=null?g:[],a=(C=(A=r==null?void 0:r.routes)==null?void 0:A.list().events)!=null?C:[],c=(D=r==null?void 0:r.proxy)!=null?D:!1,l=(V=r==null?void 0:r.rateLimits)!=null?V:{enabled:!1,list:[]},f=(G=r==null?void 0:r.bind)!=null?G:"0.0.0.0",O=(J=r==null?void 0:r.cors)!=null?J:!1,w=(X=r==null?void 0:r.port)!=null?X:2023,H=(F=r==null?void 0:r.maxBody)!=null?F:20,I=(z=r==null?void 0:r.poweredBy)!=null?z:!0,b=async(u,t)=>{switch(u){case"error":{let m=a.find(d=>d.event==="error");m?Promise.resolve(m.code(t)).catch(d=>{console.log(d),t.status(500),t.rawRes.write(`An Error occured in your Error Event (what the hell?)
var ue=Object.create;var q=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var me=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var ye=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var we=(r,e,a,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of he(e))!pe.call(r,l)&&l!==a&&q(r,l,{get:()=>e[l],enumerable:!(c=fe(e,l))||c.enumerable});return r};var E=(r,e,a)=>(a=r!=null?ue(me(r)):{},we(e||!r||!r.__esModule?q(a,"default",{value:r,enumerable:!0}):a,r));var j=ye((Te,te)=>{te.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});var N=E(require("fs")),$=(r,e)=>(e=e||[],N.readdirSync(r).forEach(c=>{if(N.statSync(r+"/"+c).isDirectory())e=$(r+"/"+c,e);else{let l=r+"/"+c;e.push(l)}}),e),ee=(r,e,a)=>(a=a||[],a=$(r,a).filter(c=>c.endsWith(e)),a);var L=E(j()),se=E(require("path")),ae=E(require("fs")),re=r=>(r=r.replace(/\/{2,}/g,"/"),r.endsWith("/")?r.slice(0,-1):r.startsWith("/")?r:`/${r}`),W=class{constructor(e,a){e=e!=null?e:[],a=a!=null?a:[],this.routes=e,this.events=a}event(e,a){return this.events.some(c=>c.event===e)?!1:this.events.push({event:e,code:a})-1}set(e,a,c){if(a=re(a),!L.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${L.default.join(", ")}`);return this.routes.some(l=>l.method===e&&l.path===a)?!1:this.routes.push({method:e,path:a,pathArray:a.split("/"),code:c,data:{addTypes:!1}})-1}static(e,a,c){var H,I,b;e=re(e);let l=(H=c==null?void 0:c.preload)!=null?H:!1,f=(I=c==null?void 0:c.remHTML)!=null?I:!1,O=(b=c==null?void 0:c.addTypes)!=null?b:!0,w=[];for(let T of $(a)){let h=T.replace(a,"").replace("/",""),g=e+a.replace(h,"").replace(a,"").slice(0,-1);g.startsWith(".")&&(g=g.slice(-1)),f&&h==="index.html"?h="":f&&h.endsWith(".html")?h=h.slice(0,-5):f&&h.endsWith(".htm")&&(h=h.slice(0,-4));let A=`${g}/${h}`.endsWith("/")?`${g}`:`${g}`=="/"?`/${h}`:`${g}/${h}`,C=this.routes.push({method:"STATIC",path:A,pathArray:A.split("/"),code:async()=>{},data:{addTypes:O,file:T}});l&&(this.routes[C-1].data.content=ae.readFileSync(T)),w.push(C-1)}return w}load(e){let a=ee(e,".js"),c=[];for(let l of a){let f=require(se.resolve(l));if(!(!("path"in f)||!("method"in f)||!("code"in f))){if(!L.default.includes(f.method))throw TypeError(`No Valid Request Type: ${f.method}
Possible Values: ${L.default.join(", ")}`);c.push(this.routes.push({method:f.method,path:f.path,pathArray:f.path.split("/"),code:f.code,data:{addTypes:!1}}))-1}}return c}list(){return{routes:this.routes,events:this.events}}};var ne=(w=>(w.options="OPTIONS",w.delete="DELETE",w.patch="PATCH",w.post="POST",w.put="PUT",w.get="GET",w.static="STATIC",w))(ne||{}),ie=ne;var oe=E(j()),ce=E(require("path")),le=E(require("http")),de=E(require("url")),M=E(require("fs"));module.exports={routeList:W,types:ie,async start(r){var h,g,A,C,D,V,G,J,X,F,z;let e=(g=(h=r==null?void 0:r.routes)==null?void 0:h.list().routes)!=null?g:[],a=(C=(A=r==null?void 0:r.routes)==null?void 0:A.list().events)!=null?C:[],c=(D=r==null?void 0:r.proxy)!=null?D:!1,l=(V=r==null?void 0:r.rateLimits)!=null?V:{enabled:!1,list:[]},f=(G=r==null?void 0:r.bind)!=null?G:"0.0.0.0",O=(J=r==null?void 0:r.cors)!=null?J:!1,w=(X=r==null?void 0:r.port)!=null?X:2023,H=(F=r==null?void 0:r.maxBody)!=null?F:20,I=(z=r==null?void 0:r.poweredBy)!=null?z:!0,b=async(u,t)=>{switch(u){case"error":{let m=a.find(d=>d.event==="error");m?Promise.resolve(m.code(t)).catch(d=>{console.log(d),t.status(500),t.rawRes.write(`An Error occured in your Error Event (what the hell?)
`),t.rawRes.write(d.stack),t.rawRes.end()}).then(()=>t.rawRes.end()):(console.log(t.error),t.rawRes.write(`An Error occurred

@@ -5,0 +5,0 @@ `),t.rawRes.write(t.error.stack),t.status(500),t.rawRes.end())}case"request":{let m=!1,d=a.find(i=>i.event==="request");return d&&await Promise.resolve(d.code(t)).catch(i=>{m=!0,console.log(i),t.status(500),t.rawRes.write(`An Error occured in your Request Event

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

var b=Object.create;var $=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var v=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+s+'" is not supported')});var C=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var L=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of H(e))!q.call(s,i)&&i!==t&&$(s,i,{get:()=>e[i],enumerable:!(r=N(e,i))||r.enumerable});return s};var M=(s,e,t)=>(t=s!=null?b(V(s)):{},L(e||!s||!s.__esModule?$(t,"default",{value:s,enumerable:!0}):t,s));var I=C((D,x)=>{x.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});import*as a from"fs";var p=(s,e)=>(e=e||[],a.readdirSync(s).forEach(r=>{if(a.statSync(s+"/"+r).isDirectory())e=p(s+"/"+r,e);else{let i=s+"/"+r;e.push(i)}}),e),A=(s,e,t)=>(t=t||[],t=p(s,t).filter(r=>r.endsWith(e)),t);var c=M(I());import*as P from"path";import*as S from"fs";var E=s=>(s=s.replace(/\/{2,}/g,"/"),s.endsWith("/")?s.slice(0,-1):s.startsWith("/")?s:`/${s}`),d=class{constructor(e,t){e=e!=null?e:[],t=t!=null?t:[],this.routes=e,this.events=t}event(e,t){return this.events.some(r=>r.event===e)?!1:this.events.push({event:e,code:t})}set(e,t,r){if(t=E(t),!c.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${c.default.join(", ")}`);return this.routes.some(i=>i.method===e&&i.path===t)?!1:this.routes.push({method:e,path:t,pathArray:t.split("/"),code:r,data:{addTypes:!1}})}static(e,t,r){var m,h,T;e=E(e);let i=(m=r==null?void 0:r.preload)!=null?m:!1,n=(h=r==null?void 0:r.remHTML)!=null?h:!1,W=(T=r==null?void 0:r.addTypes)!=null?T:!0,f=[];for(let u of p(t)){let l=u.replace(t,"").replace("/",""),o=e+t.replace(l,"").replace(t,"").slice(0,-1);o.startsWith(".")&&(o=o.slice(-1)),n&&l==="index.html"?l="":n&&l.endsWith(".html")?l=l.slice(0,-5):n&&l.endsWith(".htm")&&(l=l.slice(0,-4));let y=`${o}/${l}`.endsWith("/")?`${o}`:`${o}`=="/"?`/${l}`:`${o}/${l}`,g=this.routes.push({method:"STATIC",path:y,pathArray:y.split("/"),code:async()=>null,data:{addTypes:W,file:u}});i&&(this.routes[g].data.content=S.readFileSync(u)),f.push(g)}return f}load(e){let t=A(e,".js"),r=[];for(let i of t){let n=v(P.resolve(i));if(!(!("path"in n)||!("method"in n)||!("code"in n))){if(!c.default.includes(n.type))throw TypeError(`No Valid Request Type: ${n.method}
Possible Values: ${c.default.join(", ")}`);r.push(this.routes.push({method:n.method,path:n.path,pathArray:n.path.split("/"),code:n.code,data:{addTypes:!1}}))}}return r}list(){return{routes:this.routes,events:this.events}}};export{d as default,E as pathParser};
var b=Object.create;var $=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var V=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var v=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+s+'" is not supported')});var C=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var L=(s,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of H(e))!q.call(s,i)&&i!==t&&$(s,i,{get:()=>e[i],enumerable:!(r=N(e,i))||r.enumerable});return s};var M=(s,e,t)=>(t=s!=null?b(V(s)):{},L(e||!s||!s.__esModule?$(t,"default",{value:s,enumerable:!0}):t,s));var E=C((D,x)=>{x.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});import*as a from"fs";var d=(s,e)=>(e=e||[],a.readdirSync(s).forEach(r=>{if(a.statSync(s+"/"+r).isDirectory())e=d(s+"/"+r,e);else{let i=s+"/"+r;e.push(i)}}),e),A=(s,e,t)=>(t=t||[],t=d(s,t).filter(r=>r.endsWith(e)),t);var c=M(E());import*as P from"path";import*as S from"fs";var I=s=>(s=s.replace(/\/{2,}/g,"/"),s.endsWith("/")?s.slice(0,-1):s.startsWith("/")?s:`/${s}`),p=class{constructor(e,t){e=e!=null?e:[],t=t!=null?t:[],this.routes=e,this.events=t}event(e,t){return this.events.some(r=>r.event===e)?!1:this.events.push({event:e,code:t})-1}set(e,t,r){if(t=I(t),!c.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${c.default.join(", ")}`);return this.routes.some(i=>i.method===e&&i.path===t)?!1:this.routes.push({method:e,path:t,pathArray:t.split("/"),code:r,data:{addTypes:!1}})-1}static(e,t,r){var m,h,T;e=I(e);let i=(m=r==null?void 0:r.preload)!=null?m:!1,n=(h=r==null?void 0:r.remHTML)!=null?h:!1,W=(T=r==null?void 0:r.addTypes)!=null?T:!0,f=[];for(let u of d(t)){let o=u.replace(t,"").replace("/",""),l=e+t.replace(o,"").replace(t,"").slice(0,-1);l.startsWith(".")&&(l=l.slice(-1)),n&&o==="index.html"?o="":n&&o.endsWith(".html")?o=o.slice(0,-5):n&&o.endsWith(".htm")&&(o=o.slice(0,-4));let y=`${l}/${o}`.endsWith("/")?`${l}`:`${l}`=="/"?`/${o}`:`${l}/${o}`,g=this.routes.push({method:"STATIC",path:y,pathArray:y.split("/"),code:async()=>{},data:{addTypes:W,file:u}});i&&(this.routes[g-1].data.content=S.readFileSync(u)),f.push(g-1)}return f}load(e){let t=A(e,".js"),r=[];for(let i of t){let n=v(P.resolve(i));if(!(!("path"in n)||!("method"in n)||!("code"in n))){if(!c.default.includes(n.method))throw TypeError(`No Valid Request Type: ${n.method}
Possible Values: ${c.default.join(", ")}`);r.push(this.routes.push({method:n.method,path:n.path,pathArray:n.path.split("/"),code:n.code,data:{addTypes:!1}}))-1}}return r}list(){return{routes:this.routes,events:this.events}}};export{p as default,I as pathParser};

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

var ge=Object.create;var q=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var ee=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,a)=>(typeof require<"u"?require:e)[a]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var U=(t,e)=>()=>(t&&(e=t(t=0)),e);var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Re=(t,e,a,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Te(e))!Ee.call(t,l)&&l!==a&&q(t,l,{get:()=>e[l],enumerable:!(c=be(e,l))||c.enumerable});return t};var re=(t,e,a)=>(a=t!=null?ge(ve(t)):{},Re(e||!t||!t.__esModule?q(a,"default",{value:t,enumerable:!0}):a,t));import*as I from"fs";var N,se,ae=U(()=>{N=(t,e)=>(e=e||[],I.readdirSync(t).forEach(c=>{if(I.statSync(t+"/"+c).isDirectory())e=N(t+"/"+c,e);else{let l=t+"/"+c;e.push(l)}}),e),se=(t,e,a)=>(a=a||[],a=N(t,a).filter(c=>c.endsWith(e)),a)});var j=te((xe,ne)=>{ne.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});import*as oe from"path";import*as ce from"fs";var k,ie,L,le=U(()=>{ae();k=re(j()),ie=t=>(t=t.replace(/\/{2,}/g,"/"),t.endsWith("/")?t.slice(0,-1):t.startsWith("/")?t:`/${t}`),L=class{constructor(e,a){e=e!=null?e:[],a=a!=null?a:[],this.routes=e,this.events=a}event(e,a){return this.events.some(c=>c.event===e)?!1:this.events.push({event:e,code:a})}set(e,a,c){if(a=ie(a),!k.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${k.default.join(", ")}`);return this.routes.some(l=>l.method===e&&l.path===a)?!1:this.routes.push({method:e,path:a,pathArray:a.split("/"),code:c,data:{addTypes:!1}})}static(e,a,c){var W,H,b;e=ie(e);let l=(W=c==null?void 0:c.preload)!=null?W:!1,f=(H=c==null?void 0:c.remHTML)!=null?H:!1,$=(b=c==null?void 0:c.addTypes)!=null?b:!0,w=[];for(let T of N(a)){let h=T.replace(a,"").replace("/",""),g=e+a.replace(h,"").replace(a,"").slice(0,-1);g.startsWith(".")&&(g=g.slice(-1)),f&&h==="index.html"?h="":f&&h.endsWith(".html")?h=h.slice(0,-5):f&&h.endsWith(".htm")&&(h=h.slice(0,-4));let S=`${g}/${h}`.endsWith("/")?`${g}`:`${g}`=="/"?`/${h}`:`${g}/${h}`,A=this.routes.push({method:"STATIC",path:S,pathArray:S.split("/"),code:async()=>null,data:{addTypes:$,file:T}});l&&(this.routes[A].data.content=ce.readFileSync(T)),w.push(A)}return w}load(e){let a=se(e,".js"),c=[];for(let l of a){let f=ee(oe.resolve(l));if(!(!("path"in f)||!("method"in f)||!("code"in f))){if(!k.default.includes(f.type))throw TypeError(`No Valid Request Type: ${f.method}
Possible Values: ${k.default.join(", ")}`);c.push(this.routes.push({method:f.method,path:f.path,pathArray:f.path.split("/"),code:f.code,data:{addTypes:!1}}))}}return c}list(){return{routes:this.routes,events:this.events}}}});var de,ue,fe=U(()=>{de=(w=>(w.options="OPTIONS",w.delete="DELETE",w.patch="PATCH",w.post="POST",w.put="PUT",w.get="GET",w.static="STATIC",w))(de||{}),ue=de});import*as me from"path";import*as pe from"http";import*as ye from"url";import*as M from"fs";var Se=te((Ne,we)=>{le();fe();var he=re(j());we.exports={routeList:L,types:ue,async start(t){var h,g,S,A,D,V,G,J,X,F,z;let e=(g=(h=t==null?void 0:t.routes)==null?void 0:h.list().routes)!=null?g:[],a=(A=(S=t==null?void 0:t.routes)==null?void 0:S.list().events)!=null?A:[],c=(D=t==null?void 0:t.proxy)!=null?D:!1,l=(V=t==null?void 0:t.rateLimits)!=null?V:{enabled:!1,list:[]},f=(G=t==null?void 0:t.bind)!=null?G:"0.0.0.0",$=(J=t==null?void 0:t.cors)!=null?J:!1,w=(X=t==null?void 0:t.port)!=null?X:2023,W=(F=t==null?void 0:t.maxBody)!=null?F:20,H=(z=t==null?void 0:t.poweredBy)!=null?z:!0,b=async(u,r)=>{switch(u){case"error":{let m=a.find(d=>d.event==="error");m?Promise.resolve(m.code(r)).catch(d=>{console.log(d),r.status(500),r.rawRes.write(`An Error occured in your Error Event (what the hell?)
var ge=Object.create;var q=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,Ee=Object.prototype.hasOwnProperty;var ee=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,a)=>(typeof require<"u"?require:e)[a]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var U=(t,e)=>()=>(t&&(e=t(t=0)),e);var te=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Re=(t,e,a,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of Te(e))!Ee.call(t,l)&&l!==a&&q(t,l,{get:()=>e[l],enumerable:!(c=be(e,l))||c.enumerable});return t};var re=(t,e,a)=>(a=t!=null?ge(ve(t)):{},Re(e||!t||!t.__esModule?q(a,"default",{value:t,enumerable:!0}):a,t));import*as I from"fs";var N,se,ae=U(()=>{N=(t,e)=>(e=e||[],I.readdirSync(t).forEach(c=>{if(I.statSync(t+"/"+c).isDirectory())e=N(t+"/"+c,e);else{let l=t+"/"+c;e.push(l)}}),e),se=(t,e,a)=>(a=a||[],a=N(t,a).filter(c=>c.endsWith(e)),a)});var j=te((xe,ne)=>{ne.exports=["OPTIONS","DELETE","PATCH","STATIC","POST","PUT","GET"]});import*as oe from"path";import*as ce from"fs";var k,ie,L,le=U(()=>{ae();k=re(j()),ie=t=>(t=t.replace(/\/{2,}/g,"/"),t.endsWith("/")?t.slice(0,-1):t.startsWith("/")?t:`/${t}`),L=class{constructor(e,a){e=e!=null?e:[],a=a!=null?a:[],this.routes=e,this.events=a}event(e,a){return this.events.some(c=>c.event===e)?!1:this.events.push({event:e,code:a})-1}set(e,a,c){if(a=ie(a),!k.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${k.default.join(", ")}`);return this.routes.some(l=>l.method===e&&l.path===a)?!1:this.routes.push({method:e,path:a,pathArray:a.split("/"),code:c,data:{addTypes:!1}})-1}static(e,a,c){var W,H,b;e=ie(e);let l=(W=c==null?void 0:c.preload)!=null?W:!1,f=(H=c==null?void 0:c.remHTML)!=null?H:!1,$=(b=c==null?void 0:c.addTypes)!=null?b:!0,w=[];for(let T of N(a)){let h=T.replace(a,"").replace("/",""),g=e+a.replace(h,"").replace(a,"").slice(0,-1);g.startsWith(".")&&(g=g.slice(-1)),f&&h==="index.html"?h="":f&&h.endsWith(".html")?h=h.slice(0,-5):f&&h.endsWith(".htm")&&(h=h.slice(0,-4));let S=`${g}/${h}`.endsWith("/")?`${g}`:`${g}`=="/"?`/${h}`:`${g}/${h}`,A=this.routes.push({method:"STATIC",path:S,pathArray:S.split("/"),code:async()=>{},data:{addTypes:$,file:T}});l&&(this.routes[A-1].data.content=ce.readFileSync(T)),w.push(A-1)}return w}load(e){let a=se(e,".js"),c=[];for(let l of a){let f=ee(oe.resolve(l));if(!(!("path"in f)||!("method"in f)||!("code"in f))){if(!k.default.includes(f.method))throw TypeError(`No Valid Request Type: ${f.method}
Possible Values: ${k.default.join(", ")}`);c.push(this.routes.push({method:f.method,path:f.path,pathArray:f.path.split("/"),code:f.code,data:{addTypes:!1}}))-1}}return c}list(){return{routes:this.routes,events:this.events}}}});var de,ue,fe=U(()=>{de=(w=>(w.options="OPTIONS",w.delete="DELETE",w.patch="PATCH",w.post="POST",w.put="PUT",w.get="GET",w.static="STATIC",w))(de||{}),ue=de});import*as me from"path";import*as pe from"http";import*as ye from"url";import*as M from"fs";var Se=te((Ne,we)=>{le();fe();var he=re(j());we.exports={routeList:L,types:ue,async start(t){var h,g,S,A,D,V,G,J,X,F,z;let e=(g=(h=t==null?void 0:t.routes)==null?void 0:h.list().routes)!=null?g:[],a=(A=(S=t==null?void 0:t.routes)==null?void 0:S.list().events)!=null?A:[],c=(D=t==null?void 0:t.proxy)!=null?D:!1,l=(V=t==null?void 0:t.rateLimits)!=null?V:{enabled:!1,list:[]},f=(G=t==null?void 0:t.bind)!=null?G:"0.0.0.0",$=(J=t==null?void 0:t.cors)!=null?J:!1,w=(X=t==null?void 0:t.port)!=null?X:2023,W=(F=t==null?void 0:t.maxBody)!=null?F:20,H=(z=t==null?void 0:t.poweredBy)!=null?z:!0,b=async(u,r)=>{switch(u){case"error":{let m=a.find(d=>d.event==="error");m?Promise.resolve(m.code(r)).catch(d=>{console.log(d),r.status(500),r.rawRes.write(`An Error occured in your Error Event (what the hell?)
`),r.rawRes.write(d.stack),r.rawRes.end()}).then(()=>r.rawRes.end()):(console.log(r.error),r.rawRes.write(`An Error occurred

@@ -5,0 +5,0 @@ `),r.rawRes.write(r.error.stack),r.status(500),r.rawRes.end())}case"request":{let m=!1,d=a.find(i=>i.event==="request");return d&&await Promise.resolve(d.code(r)).catch(i=>{m=!0,console.log(i),r.status(500),r.rawRes.write(`An Error occured in your Request Event

{
"name": "rjweb-server",
"version": "2.1.2",
"version": "2.1.3",
"description": "Easy and Lightweight Way to create a Web Server with Many Features",

@@ -5,0 +5,0 @@ "module": "lib/esm/index.js",

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