Socket
Socket
Sign inDemoInstall

rjweb-server

Package Overview
Dependencies
Maintainers
1
Versions
373
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.1 to 2.1.2

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:()=>d,pathParser:()=>h});module.exports=j(w);var u=p(require("fs")),f=(s,e)=>(e=e||[],u.readdirSync(s).forEach(r=>{if(u.statSync(s+"/"+r).isDirectory())e=f(s+"/"+r,e);else{let i=s+"/"+r;e.push(i)}}),e),I=(s,e,t)=>(t=t||[],t=f(s,t).filter(r=>r.endsWith(e)),t);var o=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}`),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=h(t),!o.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${o.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 T,g,$;e=h(e);let i=(T=r==null?void 0:r.preload)!=null?T:!1,n=(g=r==null?void 0:r.remHTML)!=null?g:!1,b=($=r==null?void 0:r.addTypes)!=null?$:!0,y=[];for(let m of f(t)){let l=m.replace(t,"").replace("/",""),c=e+t.replace(l,"").replace(t,"").slice(0,-1);c.startsWith(".")&&(c=c.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=`${c}/${l}`.endsWith("/")?`${c}`:`${c}`=="/"?`/${l}`:`${c}/${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)),y.push(A)}return y}load(e){let t=I(e,".js"),r=[];for(let i of t){let n=require(S.resolve(i));if(!(!("path"in n)||!("type"in n)||!("code"in n))){if(!o.default.includes(n.type))throw TypeError(`No Valid Request Type: ${n.type}
Possible Values: ${o.default.join(", ")}`);r.push(this.routes.push({method:n.type,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 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 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)||!("type"in f)||!("code"in f))){if(!L.default.includes(f.type))throw TypeError(`No Valid Request Type: ${f.type}
Possible Values: ${L.default.join(", ")}`);c.push(this.routes.push({method:f.type,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?)
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?)
`),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

@@ -6,3 +6,3 @@ import ctr from "./ctr";

/** The Route Path */ path: string;
/** The Async Code to Run */ code: (ctr: ctr<Custom, false, Body>) => Promise<any>;
/** The Async Code to run on a Request */ code: (ctr: ctr<Custom, false, Body>) => Promise<any>;
}

@@ -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 o=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}`),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=E(t),!o.default.includes(e))throw TypeError(`No Valid Request Type: ${e}
Possible Values: ${o.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,y;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=(y=r==null?void 0:r.addTypes)!=null?y:!0,d=[];for(let u of p(t)){let l=u.replace(t,"").replace("/",""),c=e+t.replace(l,"").replace(t,"").slice(0,-1);c.startsWith(".")&&(c=c.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 T=`${c}/${l}`.endsWith("/")?`${c}`:`${c}`=="/"?`/${l}`:`${c}/${l}`,g=this.routes.push({method:"STATIC",path:T,pathArray:T.split("/"),code:async()=>null,data:{addTypes:W,file:u}});i&&(this.routes[g].data.content=S.readFileSync(u)),d.push(g)}return d}load(e){let t=A(e,".js"),r=[];for(let i of t){let n=v(P.resolve(i));if(!(!("path"in n)||!("type"in n)||!("code"in n))){if(!o.default.includes(n.type))throw TypeError(`No Valid Request Type: ${n.type}
Possible Values: ${o.default.join(", ")}`);r.push(this.routes.push({method:n.type,path:n.path,pathArray:n.path.split("/"),code:n.code,data:{addTypes:!1}}))}}return r}list(){return{routes:this.routes,events:this.events}}};export{f 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 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 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)||!("type"in f)||!("code"in f))){if(!k.default.includes(f.type))throw TypeError(`No Valid Request Type: ${f.type}
Possible Values: ${k.default.join(", ")}`);c.push(this.routes.push({method:f.type,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?)
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?)
`),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

@@ -6,3 +6,3 @@ import ctr from "./ctr";

/** The Route Path */ path: string;
/** The Async Code to Run */ code: (ctr: ctr<Custom, false, Body>) => Promise<any>;
/** The Async Code to run on a Request */ code: (ctr: ctr<Custom, false, Body>) => Promise<any>;
}
{
"name": "rjweb-server",
"version": "2.1.1",
"version": "2.1.2",
"description": "Easy and Lightweight Way to create a Web Server with Many Features",

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

@@ -67,3 +67,3 @@ <h1 align="center">Welcome to rjweb-server v2 👋</h1>

interface ctr<HasError = false> extends ctrPreset<Custom, HasError> {}
interface ctr<HasError = false, Body = any> extends ctrPreset<Custom, HasError, Body> {}

@@ -313,3 +313,3 @@ const routes = new webserver.routeList()

module.exports = {
type: webserver.types.get,
method: webserver.types.get,
path: '/say/:word',

@@ -316,0 +316,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