@virid/express 0.1.3 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -33
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
package/dist/index.cjs
CHANGED
|
@@ -1,40 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @virid/express v0.
|
|
2
|
+
* @virid/express v0.2.2
|
|
3
3
|
* Add express functionality to virid
|
|
4
4
|
*/
|
|
5
|
-
var
|
|
5
|
+
var P=Object.defineProperty;var Oe=Object.getOwnPropertyDescriptor;var Ce=Object.getOwnPropertyNames;var Pe=Object.prototype.hasOwnProperty;var Te=(t,e,s)=>e in t?P(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var o=(t,e)=>P(t,"name",{value:e,configurable:!0});var ve=(t,e)=>{for(var s in e)P(t,s,{get:e[s],enumerable:!0})},He=(t,e,s,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ce(e))!Pe.call(t,n)&&n!==s&&P(t,n,{get:()=>e[n],enumerable:!(r=Oe(e,n))||r.enumerable});return t};var Ie=t=>He(P({},"__esModule",{value:!0}),t);var p=(t,e,s)=>Te(t,typeof e!="symbol"?e+"":e,s);var ot={};ve(ot,{BadRequest:()=>be,BadRequestResponse:()=>V,Body:()=>ze,ConflictResponse:()=>X,Cookies:()=>Le,Created:()=>$e,CreatedResponse:()=>q,Ctx:()=>Ze,CustomResponse:()=>Qe,CustomResponseResponse:()=>Q,ExpressPlugin:()=>st,Forbidden:()=>De,ForbiddenResponse:()=>N,Headers:()=>Ke,HttpContext:()=>T,HttpError:()=>w,HttpRequestMessage:()=>H,HttpResponse:()=>u,HttpRoute:()=>Fe,HttpSystem:()=>Xe,InternalServerError:()=>U,InternalServerErrorResponse:()=>B,NoContent:()=>Ve,NoContentResponse:()=>$,NotFound:()=>Be,NotFoundResponse:()=>D,Ok:()=>qe,OkResponse:()=>I,Params:()=>et,ParseBoolPipe:()=>xe,ParseIntPipe:()=>he,Query:()=>ke,Req:()=>Ge,Res:()=>Je,Stream:()=>Ye,StreamFile:()=>Ue,StreamFileResponse:()=>R,StreamResponse:()=>y,Unauthorized:()=>Ne,UnauthorizedResponse:()=>b,UnprocessableEntityResponse:()=>z,addAutoPipe:()=>We,getAutoPipe:()=>Y,parseRawCookie:()=>pe});module.exports=Ie(ot);var ge=require("@virid/core");var W=require("@virid/core");var S=require("@virid/core");var fe=require("@virid/core");var K=class K{constructor(e,s,r,n,d){p(this,"id");p(this,"req");p(this,"res");p(this,"timestamp");p(this,"route");p(this,"rc",0);p(this,"isClosed",!1);this.id=e,this.req=s,this.res=r,this.timestamp=n,this.route=d}inc(){this.rc++}dec(){this.rc--,this.rc===0&&this.tryFinalize()}tryFinalize(){if(this.res.writableEnded||this.isClosed)return;this.isClosed=!0;let e=`[Virid Express] Request Orphaned: The connection was closed because all systems finished execution without sending a response.
|
|
6
6
|
Route: ${this.route}
|
|
7
|
-
Uptime: ${Date.now()-this.timestamp}ms`;
|
|
8
|
-
|
|
9
|
-
MessageName: ${t.message.constructor.name}
|
|
10
|
-
MessageData: ${JSON.stringify(t.message)}`))}catch(s){p.error(s,`[Virid Dispatcher]: Sync System Error.
|
|
11
|
-
SystemLocation: ${t.hookContext.context.targetClass.name}.${t.hookContext.context.methodName}
|
|
12
|
-
MessageName: ${t.message.constructor.name}
|
|
13
|
-
MessageData: ${JSON.stringify(t.message)}`)}}prepareSnapshot(){this.eventHub.flip();let e=new Set(this.dirtySignalTypes),t=[...this.eventQueue];return this.dirtySignalTypes.clear(),this.eventQueue=[],{signalSnapshot:e,eventSnapshot:t}}clear(e,t){let s=new Set(t);e.forEach(n=>s.add(n.constructor)),this.eventHub.clearSignals(s),this.eventHub.clearEvents()}executeTickHooks(e){let t={tick:this.globalTick,timestamp:Date.now(),payload:this.tickPayload};e.forEach(s=>s(t))}},i(F,"K"),F);c(dt,"Dispatcher");var Yt=dt,W,ut=(W=class{constructor(e,t,s,n){l(this,"fn"),l(this,"priority"),l(this,"message"),l(this,"hookContext"),this.fn=e,this.priority=t,this.message=s,this.hookContext=n}triggerHooks(e){let t=Array.isArray(this.message)?this.message[0]:this.message;if(t){for(let s of e)if(t instanceof s.type)try{let n=s.handler(this.message,this.hookContext);n instanceof Promise&&n.catch(o=>{p.error(o,`[Virid Hook] Async Hook Error:
|
|
14
|
-
It is prohibited to use asynchronous hooks within Hook:
|
|
15
|
-
${s.type.name}`)})}catch(n){p.error(n,`[Virid Hook] Hook Execute Failed:
|
|
16
|
-
Triggered by: ${t.constructor.name}
|
|
17
|
-
Registered type: ${s.type.name}`)}}}execute(e,t){this.triggerHooks(e);let s=c(()=>this.triggerHooks(t),"runAfter");try{let n=this.fn(this.message);return n instanceof Promise?n.finally(()=>s()):(s(),n)}catch(n){throw s(),n}}},i(W,"X"),W);c(ut,"ExecutionTask");var Je=ut,U,ht=(U=class{constructor(){l(this,"signalActive",new Map),l(this,"signalStaging",new Map),l(this,"eventActive",[]),l(this,"eventStaging",[])}push(e){if(e instanceof xe){let t=e.constructor;this.signalStaging.has(t)||this.signalStaging.set(t,[]),this.signalStaging.get(t).push(e)}else e instanceof $?this.eventStaging.push(e):p.error(new Error(`[Virid Message] Invalid Message:
|
|
18
|
-
${e.constructor.name} must extend SingleMessage or EventMessage`))}flip(){this.signalActive=this.signalStaging,this.signalStaging=new Map,this.eventActive=this.eventStaging,this.eventStaging=[]}peekSignal(e){return this.signalActive.get(e)||[]}getEventStream(){return this.eventActive}peekEventAt(e){return this.eventActive[e]}clearSignals(e){e.forEach(t=>this.signalActive.delete(t))}clearEvents(){this.eventActive=[]}reset(){this.signalActive.clear(),this.signalStaging.clear(),this.eventActive=[],this.eventStaging=[]}},i(U,"Z"),U);c(ht,"EventHub");var Kt=ht,L,pt=(L=class{constructor(){l(this,"systemTaskMap",new Map)}register(e,t,s=0){let n=this.systemTaskMap.get(e)||[];if(n.findIndex(o=>o.fn===t)===-1)n.push({fn:t,priority:s}),n.sort((o,a)=>a.priority-o.priority),this.systemTaskMap.set(e,n);else{let o=t.name||"Anonymous";return p.error(new Error(`[Virid Error] System Already Registered:
|
|
19
|
-
Class ${e.name}
|
|
20
|
-
Function ${o}`)),()=>{}}return()=>{let o=this.systemTaskMap.get(e);if(o){let a=o.findIndex(d=>d.fn===t);a!==-1&&(o.splice(a,1),o.length===0&&this.systemTaskMap.delete(e))}}}},i(L,"ee"),L);c(pt,"MessageRegistry");var Xt=pt,G,ft=(G=class{constructor(){l(this,"eventHub",new Kt),l(this,"dispatcher",new Yt(this.eventHub)),l(this,"registry",new Xt),l(this,"middlewares",[]),ct(this)}useMiddleware(e,t){this.middlewares.push(e)}onBeforeExecute(e,t,s){this.dispatcher.addBeforeExecute(e,t,s)}onAfterExecute(e,t,s){this.dispatcher.addAfterExecute(e,t,s)}onBeforeTick(e,t){this.dispatcher.addBeforeTick(e,t)}onAfterTick(e,t){this.dispatcher.addAfterTick(e,t)}dispatch(e){if(!(e instanceof ye)){p.error(new Error(`[Virid Dispatch] Type Error: Message must be an instance of BaseMessage,message:${e}`));return}this.pipeline(e,()=>{if(!this.registry.systemTaskMap.has(e.constructor)){p.error(new Error(`[Virid Dispatch] No handler for message: ${e.constructor.name}`));return}this.eventHub.push(e),this.dispatcher.markDirty(e),this.dispatcher.tick(this.registry.systemTaskMap)})}pipeline(e,t){let s=0,n=c(()=>{s<this.middlewares.length?this.middlewares[s++](e,n):t()},"next");n()}register(e,t,s=0){return this.registry.register(e,t,s)}},i(G,"te"),G);c(ft,"MessageInternal");var Jt=ft,z,gt=(z=class{constructor(){l(this,"bindings",new Map),l(this,"singletonInstances",new Map)}bind(e){let t={type:"transient",ctor:e};return this.bindings.set(e,t),{toSelf:c(()=>({inSingletonScope:c(()=>(t.type="singleton",{onActivation:c(s=>{},"onActivation")}),"inSingletonScope")}),"toSelf")}}get(e,t){let s=this.bindings.get(e);if(!s)throw new Error(`[Virid Container] Unbound Constructor: No binding found for ${e.name}`);let n=s.ctor;if(s.type==="singleton"){if(!this.singletonInstances.has(e)){let a=new n,d=t(a);this.singletonInstances.set(e,d)}return this.singletonInstances.get(e)}let o=new n;return t(o)}},i(z,"re"),z);c(gt,"ViridContainer");var Zt=gt,h={reset:"\x1B[0m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",gray:"\x1B[90m",bold:"\x1B[1m",green:"\x1B[32m"};function J(r,e,t){let s={params:r,targetClass:Object,methodName:t,originalMethod:e};return e.ccsContext=s,e}i(J,"N");c(J,"withContext");var er=c(r=>{let e=`${h.green}${h.bold} \u2714 [Virid Info] ${h.reset}`,t=`${h.magenta}${r.context}${h.reset}`;console.log(`${e}${h.gray}Global Info Caught:${h.reset}
|
|
21
|
-
${h.green}Details:${h.reset}`,r.context||"unknown Info")},"globalInfoHandler"),tr=c(r=>{let e=`${h.red}${h.bold} \u2716 [Virid Error] ${h.reset}`,t=`${h.magenta}${r.context}${h.reset}`;console.error(`${e}${h.gray}Global Error Caught:${h.reset}
|
|
22
|
-
${h.red}Context:${h.reset} ${t}
|
|
23
|
-
${h.red}Details:${h.reset}`,r.error||r||"unknown Error")},"globalErrorHandler"),rr=c(r=>{let e=`${h.yellow}${h.bold} \u26A0 [Virid Warn] ${h.reset}`,t=`${h.cyan}${r.context}${h.reset}`;console.warn(`${e}${h.gray}Global Warn Caught:${h.reset}
|
|
24
|
-
${h.yellow}Context:${h.reset} ${t}`)},"globalWarnHandler"),sr=c(r=>{let e=Z.get(r.ComponentClass);if(!e){console.error(`[Virid Modify] Component Not Found:
|
|
25
|
-
Component ${r.ComponentClass.name} not found in Registry.`);return}try{r.recipe(e),p.warn(`[Virid Modify] Successfully:
|
|
26
|
-
Modify on ${r.ComponentClass.name}
|
|
27
|
-
label: ${r.label}`)}catch(t){p.error(t,`[Virid Error] Modify Failed:
|
|
28
|
-
${r.label}`)}},"atomicModifyHandler");function mt(r){r.register(Xe,J(Xe,sr,"GlobalAtomicModifier"),1e3),r.register(Le,J(Le,rr,"GlobalWarnHandler"),-999),r.register(Ue,J(Ue,tr,"GlobalErrorHandler"),-999),r.register(Ge,J(Ge,er,"GlobalInfoHandler"),-999),Z=r}i(mt,"le");c(mt,"initializeGlobalSystems");var Z=null,Ir=new Proxy({},{get(r,e){return(...t)=>{if(!Z){console.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`);return}let s=Z[e];if(typeof s=="function")return s.apply(Z,t)}}}),Ze=new Set,Y,yt=(Y=class{constructor(){l(this,"container",new Zt),l(this,"messageInternal",new Jt),l(this,"activationHooks",[])}addActivationHook(e){this.activationHooks.push(e)}get(e){return e.length>0&&p.error(new Error(`[Virid Container] Violation: Component "${e.name}" should not have constructor arguments. Dependency Injection is only allowed in Systems.`)),this.container.get(e,t=>this.handleActivation(t))}handleActivation(e){return e&&this.activationHooks.reduce((t,s)=>{try{let n=s(t);return n===void 0&&p.warn(`[Virid Container] Hook Does Bot Return A Value: Hook "${s.name}" should return a instance to continue.`),n!==void 0?n:t}catch(n){return p.error(n,"[Virid Container] Activation Hook Failed"),t}},e)}bindController(e){return this.container.bind(e).toSelf(),{inSingletonScope:c(()=>({onActivation:c(()=>{},"onActivation")}),"inSingletonScope")}}bindComponent(e){return this.container.bind(e).toSelf().inSingletonScope(),{onActivation:c(()=>{},"onActivation")}}useMiddleware(e,t=!1){this.messageInternal.useMiddleware(e,t)}onBeforeExecute(e,t,s=!1){this.messageInternal.onBeforeExecute(e,t,s)}onAfterExecute(e,t,s=!1){this.messageInternal.onAfterExecute(e,t,s)}onBeforeTick(e,t=!1){this.messageInternal.onBeforeTick(e,t)}onAfterTick(e,t=!1){this.messageInternal.onAfterTick(e,t)}register(e,t,s=0){return this.messageInternal.register(e,t,s)}use(e,t){if(Ze.has(e.name))return p.warn(`[Virid Plugin] Duplicate Installation: Plugin ${e.name} has already been installed.`),this;try{e.install(this,t),Ze.add(e.name)}catch(s){p.error(s,`[Virid Plugin]: Install Failed: ${e.name}`)}return this}},i(Y,"ne"),Y);c(yt,"ViridApp");var nr=yt,ee=new nr;ee.addActivationHook(me);mt(ee);var b={SYSTEM:"virid:core:system",MESSAGE:"virid:core:message",CONTROLLER:"virid:core:controller",COMPONENT:"virid:core:component",SAFE:"virid:core:safe",OBSERVER:"virid:core:observer"},ge=c(r=>{r&&(Array.isArray(r)?r:[r]).forEach(e=>{e instanceof ye?p.write(e):p.warn("[Virid HandleResult] Invalid Return Type: Must return Message or Message[].")})},"handleResult");function ir(r={priority:0,messageClass:null}){return(e,t,s)=>{let n=s.value,o=Reflect.getMetadata("design:paramtypes",e,t),a=Reflect.getMetadata(b.MESSAGE,e,t)||null;if(!o){let g=new Error(`[Virid System] System Parameter Loss:
|
|
29
|
-
Unable to recognize system parameters, please confirm if import "reflection-metadata" was introduced at the beginning!`);p.error(g);return}if(o.some(g=>g===void 0)){let g=new Error(`[Virid System] Parameter Metadata Loss in "${t}":
|
|
7
|
+
Uptime: ${Date.now()-this.timestamp}ms`;fe.MessageWriter.error(new Error(e)),this.res.headersSent?this.res.end():this.res.status(500).json({error:"Internal Logic Error",message:"Request processed but no response was returned by any system."})}};o(K,"HttpContext");var T=K,L=class L{constructor(e,s=null,r={}){p(this,"status");p(this,"data");p(this,"headers");this.status=e,this.data=s,this.headers=r}};o(L,"HttpResponse");var u=L,G=class G extends u{constructor(e,s={}){super(200,e,s)}};o(G,"OkResponse");var I=G,J=class J extends u{constructor(e,s={}){super(201,e,s)}};o(J,"CreatedResponse");var q=J,Z=class Z extends u{constructor(){super(204,null)}};o(Z,"NoContentResponse");var $=Z,k=class k extends u{constructor(e="Bad Request"){super(400,{error:e})}};o(k,"BadRequestResponse");var V=k,ee=class ee extends u{constructor(e="Unauthorized"){super(401,{error:e})}};o(ee,"UnauthorizedResponse");var b=ee,te=class te extends u{constructor(e="Forbidden"){super(403,{error:e})}};o(te,"ForbiddenResponse");var N=te,re=class re extends u{constructor(e="Not Found"){super(404,{error:e})}};o(re,"NotFoundResponse");var D=re,se=class se extends u{constructor(e="Conflict"){super(409,{error:e})}};o(se,"ConflictResponse");var X=se,oe=class oe extends u{constructor(e){super(422,{errors:e})}};o(oe,"UnprocessableEntityResponse");var z=oe,ne=class ne extends u{constructor(e="Internal Server Error"){super(500,{error:e})}};o(ne,"InternalServerErrorResponse");var B=ne,ae=class ae extends u{constructor(e,s,r={}){super(e,s,r)}};o(ae,"CustomResponseResponse");var Q=ae,ie=class ie extends u{constructor(s,r={dotfiles:"allow"}){super(206,r);p(this,"filePath");p(this,"options");this.filePath=s,this.options=r}};o(ie,"StreamFileResponse");var R=ie,de=class de extends u{constructor(s,r={}){super(r.status||206,{},r.headers);p(this,"stream");p(this,"options");this.stream=s,this.options=r}};o(de,"StreamResponse");var y=de,qe=o((t,e={})=>new I(t,e),"Ok"),$e=o((t,e={})=>new q(t,e),"Created"),Ve=o(()=>new $,"NoContent"),be=o((t="Bad Request")=>new V(t),"BadRequest"),Ne=o((t="Unauthorized")=>new b(t),"Unauthorized"),De=o((t="Forbidden")=>new N(t),"Forbidden"),Be=o((t="Not Found")=>new D(t),"NotFound"),U=o((t="Internal Server Error")=>new B(t),"InternalServerError"),Qe=o((t,e,s={})=>new Q(t,e,s),"CustomResponse"),Ue=o((t,e)=>new R(t,e),"StreamFile"),Ye=o((t,e)=>new y(t,e),"Stream"),ce=class ce extends Error{constructor(s,r){super(r);p(this,"status");p(this,"message");this.status=s,this.message=r}};o(ce,"HttpError");var w=ce;var m=new Map;function A(t,e){if(!t){e.dec();return}(Array.isArray(t)?t:[t]).forEach(r=>{r instanceof u?je(r,e):r instanceof w?(e.res.status(r.status).json(r.message),m.delete(e.id)):r instanceof S.BaseMessage?S.MessageWriter.write(r):S.MessageWriter.warn(`[Virid Express] Invalid Return Type: ${typeof r}. Expected HttpResponse or Message.`)}),e.dec()}o(A,"handleResult");function je(t,e){let{res:s}=e;if(t.headers&&Object.entries(t.headers).forEach(([r,n])=>s.setHeader(r,n)),t.status&&s.status(t.status),t instanceof R){e.inc(),s.sendFile(t.filePath,t.options,r=>{s.headersSent||S.MessageWriter.error(r,`[Virid Express] SteamFile Error: Path: ${t.filePath}`),e.res.end(),m.delete(e.id),e.isClosed=!0,e.dec()});return}if(t instanceof y){let{stream:r}=t;e.inc(),r.pipe(s);let n=o(()=>{m.has(e.id)&&(e.res.end(),m.delete(e.id),e.isClosed=!0,e.dec())},"cleanup");r.on("end",n),r.on("error",d=>{s.headersSent||S.MessageWriter.error(d,"[Virid Express] Stream Error"),n()}),r.on("close",n);return}s.status(t.status).json(t.data),m.delete(e.id)}o(je,"handleHttpResponse");var me=require("@virid/core");function he(t){let e=parseInt(t,10);if(isNaN(e))throw new w(400,`Validation failed: "${t}" is not a number.`);return e}o(he,"ParseIntPipe");function xe(t){return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:!!t}o(xe,"ParseBoolPipe");var v=new Map;v.set(Number,he);v.set(Boolean,xe);function We(t,e){if(v.has(t)){me.MessageWriter.error(new Error(`[Virid Express Pipe] Repeated Pipe: Auto pipe for ${t} has already been registered.`));return}v.set(t,e)}o(We,"addAutoPipe");function Y(t){return v.get(t)}o(Y,"getAutoPipe");function pe(t){let e={};if(!t)return e;let s=t.split(";");for(let r of s){let n=r.indexOf("=");if(n===-1)continue;let d=r.substring(0,n).trim();if(!d)continue;let a=r.substring(n+1).trim();a[0]==='"'&&a[a.length-1]==='"'&&(a=a.slice(1,-1));try{e[d]=a.includes("%")?decodeURIComponent(a):a}catch{e[d]=a}}return e}o(pe,"parseRawCookie");var Me=require("@virid/core");var ue=class ue extends Me.EventMessage{constructor(s){super();p(this,"__virid_express_id");this.__virid_express_id=s,m.get(this.__virid_express_id).inc()}get requestId(){return this.__virid_express_id}};o(ue,"HttpRequestMessage");var H=ue;var j=new W.MessageRegistry,_=new Map,_e=0;function Ee(t){for(let[e,s]of j.systemTaskMap.entries())for(let r of s)t.register(e,r.fn,r.priority);j.systemTaskMap.clear()}o(Ee,"registerHttpSystem");function we(t){for(let[e,s]of _.entries()){let{method:r,path:n,httpMessage:d}=s,a=r.toLowerCase();t[a](n,(x,f)=>{let c=_e++>>>0;m.set(c,new T(c,x,f,Date.now(),n));let O=new d(c);f.once("finish",()=>m.delete(c)),f.once("close",()=>m.delete(c)),W.MessageWriter.write(O)})}}o(we,"registerHttpRoute");var F=null;function Se(t,e){F=t,Ee(t),we(e.server)}o(Se,"activateApp");var Re=new Proxy({},{get(t,e){return(...s)=>{if(!F)return ge.MessageWriter.warn(`[Virid Vue] App method "${String(e)}" called before initialization.`),null;let r=F[e];if(typeof r=="function")return Reflect.apply(r,F,s)}}});var h=require("@virid/core");var ye=require("@virid/core"),i={...ye.VIRID_METADATA,HTTPROUTE:"virid:express:route",HTTPSYSTEM:"virid:express:system",BODY:"virid:express:body",QUERY:"virid:express:query",HEADERS:"virid:express:header",REQUEST:"virid:express:request",RESPONSE:"virid:express:response",CONTEXT:"virid:express:context",PARAMS:"virid:express:params",COOKIES:"virid:express:cookie"};function Fe(t){return e=>{let s=`${t.method}:${t.path}`;_.has(s)&&h.MessageWriter.error(new Error(`[Virid Http] Routing Conflict: The request method ${t.method} for path ${t.path} has already been registered by ${e.name}`));let r=[];t.path.split("/").forEach(a=>{a.startsWith(":")&&r.push(a.substring(1))});let d={...t,httpMessage:e,params:r};_.set(s,d)}}o(Fe,"HttpRoute");function Xe(t={priority:0,messageClass:null}){return(e,s,r)=>{let n=r.value,d=Reflect.getMetadata("design:paramtypes",e,s),a=Reflect.getMetadata(i.MESSAGE,e,s)||null,x=tt(e,s,d);if(!d){let M=new Error(`[Virid HttpSystem] System Parameter Loss:
|
|
8
|
+
Unable to recognize system parameters, please confirm if import "reflection-metadata" was introduced at the beginning!`);h.MessageWriter.error(M);return}if(d.some(M=>M===void 0)){let M=new Error(`[Virid HttpSystem] Parameter Metadata Loss in "${s}":
|
|
30
9
|
One or more parameters have 'undefined' types.
|
|
31
10
|
This usually happens when you forget to add a type annotation to a decorated parameter.
|
|
32
|
-
Check parameter at index: ${
|
|
33
|
-
Please declare the message type using the Message decorator`));return}let
|
|
34
|
-
|
|
35
|
-
One or more parameters have 'undefined' types.
|
|
36
|
-
This usually happens when you forget to add a type annotation to a decorated parameter.
|
|
37
|
-
Check parameter at index: ${o.indexOf(void 0)}`);S.MessageWriter.error(E);return}if(r.messageClass&&a){S.MessageWriter.error(new Error(`[Virid HttpSystem] Multiple Messages Are Not Allowed: Cannot use @ message() and SystemParams simultaneously in ${t}`));return}if(!r.messageClass&&!a){S.MessageWriter.error(new Error(`[Virid HttpSystem] System Parameter Loss:
|
|
38
|
-
Please declare the message type using the Message decorator`));return}let f=r.messageClass??a.messageClass;if(!re.isPrototypeOf(f)){S.MessageWriter.error(new Error(`[Virid HttpSystem] Wrong Message Type: ${f.name} is not a derived subclass of HttpRequestMessage!`));return}let u=i(E=>{let w=v.get(E.requestId);if(!w)throw new Error(`[Virid Express HttpSystem] Invalid Request Context: The request context for message ${E.requestId} is missing.`);try{let x=o.map((C,T)=>{if(a&&a.index==T){if(!(E instanceof f)){let be=E.constructor.name;throw new Error(`[Virid Express HttpSystem] Type Mismatch: Expected ${f.name}, but received ${be}`)}return E}else return kr(C,T,w,d)}),A=n.apply(e,x);return A instanceof Promise?A.then(C=>{V(C,w)}).catch(C=>{throw V(pe(),w),C}):V(A,w)}catch(x){throw x instanceof k?V(x,w):V(pe(),w),x}},"wrappedSystem"),g={params:o,targetClass:e,methodName:t,originalMethod:n};u.systemContext=g,s.value=u,Ee.register(f,u,r.priority)}}i(mr,"HttpSystem");function yr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.BODY,r,e)){S.MessageWriter.error(new Error(`[Virid Express Body] Multiple Body Are Not Allowed: ${e} has multiple @Body() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.BODY,s,r,e)}}i(yr,"Body");function xr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.HEADERS,r,e)){S.MessageWriter.error(new Error(`[Virid Express Headers] Multiple Header Are Not Allowed: ${e} has multiple @Headers() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.HEADERS,s,r,e)}}i(xr,"Headers");function Mr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.COOKIES,r,e)){S.MessageWriter.error(new Error(`[Virid Express Cookies] Multiple Header Are Not Allowed: ${e} has multiple @Cookies() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.COOKIES,s,r,e)}}i(Mr,"Cookies");function Er(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.REQUEST,r,e)){S.MessageWriter.error(new Error(`[Virid Express Req] Multiple Request Objects Are Not Allowed: ${e} has multiple @Req() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.REQUEST,s,r,e)}}i(Er,"Req");function wr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.RESPONSE,r,e)){S.MessageWriter.error(new Error(`[Virid Express Res] Multiple Response Objects Are Not Allowed: ${e} has multiple @Res() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.RESPONSE,s,r,e)}}i(wr,"Res");function vr(){return(r,e,t)=>{if(Reflect.hasOwnMetadata(m.CONTEXT,r,e)){S.MessageWriter.error(new Error(`[Virid Express Ctx] Multiple Context Objects Are Not Allowed: ${e} has multiple @Ctx() decorators!`));return}let s={index:t};Reflect.defineMetadata(m.CONTEXT,s,r,e)}}i(vr,"Ctx");function Sr(r,e){return(t,s,n)=>{let a=[...Reflect.getOwnMetadata(m.QUERY,t,s)||[],{index:n,query:r,pipe:e}];Reflect.defineMetadata(m.QUERY,a,t,s)}}i(Sr,"Query");function br(r,e){return(t,s,n)=>{let a=[...Reflect.getOwnMetadata(m.PARAMS,t,s)||[],{index:n,key:r,pipe:e}];Reflect.defineMetadata(m.PARAMS,a,t,s)}}i(br,"Params");function Ar(r,e,t){let s=Reflect.getOwnMetadata(m.BODY,r,e),n=Reflect.getOwnMetadata(m.HEADERS,r,e),o=Reflect.getOwnMetadata(m.COOKIES,r,e),a=Reflect.getOwnMetadata(m.RESPONSE,r,e),d=Reflect.getOwnMetadata(m.REQUEST,r,e),f=Reflect.getOwnMetadata(m.CONTEXT,r,e),g=(Reflect.getOwnMetadata(m.QUERY,r,e)||[]).map(x=>{if(!x.pipe){let A=t[x.index];x.pipe=Me(A)}return x}),w=(Reflect.getOwnMetadata(m.PARAMS,r,e)||[]).map(x=>{if(!x.pipe){let A=t[x.index];x.pipe=Me(A)}return x});return{bodyMeta:s,headerMeta:n,queryMeta:g,cookiesMeta:o,reqMeta:d,resMeta:a,ctxMeta:f,paramMeta:w}}i(Ar,"getHttpMetadata");function kr(r,e,t,s){let{req:n,res:o}=t;if(s.ctxMeta?.index===e)return t;let a=s.paramMeta?.find(u=>u.index===e);if(a){let u=a.key?n.params[a.key]:n.params;return a.pipe&&u!==void 0&&(u=a.pipe(u)),u}if(s.bodyMeta?.index===e)return n.body;if(s.headerMeta?.index===e)return n.headers;if(s.cookiesMeta?.index===e)return ze(n.headers.cookie);if(s.reqMeta?.index===e)return n;if(s.resMeta?.index===e)return o;let d=s.queryMeta?.find(u=>u.index===e);if(d){let u=n.query[d.query];if(u===void 0)throw new Error(`[Virid Express] Missing Query: "${d.query}"`);return d.pipe&&(u=d.pipe(u)),u}let f=At.get(r);if(!f)throw new Error(`[Virid System] Unknown Inject Type: ${r?.name||"Anonymous Class"} at index ${e}.
|
|
39
|
-
Ensure it is registered in the IOC container or has a proper Http Decorator!`);return f}i(kr,"getHttpSystemArgs");var Cr={name:"@virid/express",install(r,e){bt(r,e)}};0&&(module.exports={BadRequest,BadRequestResponse,Body,ConflictResponse,Cookies,Created,CreatedResponse,Ctx,CustomResponse,CustomResponseResponse,ExpressPlugin,Forbidden,ForbiddenResponse,Headers,HttpContext,HttpError,HttpRequestMessage,HttpResponse,HttpRoute,HttpSystem,InternalServerError,InternalServerErrorResponse,NoContent,NoContentResponse,NotFound,NotFoundResponse,Ok,OkResponse,Params,ParseBoolPipe,ParseIntPipe,Query,Req,Res,Stream,StreamFile,StreamFileResponse,StreamResponse,Unauthorized,UnauthorizedResponse,UnprocessableEntityResponse,addAutoPipe,getAutoPipe,parseRawCookie});
|
|
11
|
+
Check parameter at index: ${d.indexOf(void 0)}`);h.MessageWriter.error(M);return}if(t.messageClass&&a){h.MessageWriter.error(new Error(`[Virid HttpSystem] Multiple Messages Are Not Allowed: Cannot use @ message() and SystemParams simultaneously in ${s}`));return}if(!t.messageClass&&!a){h.MessageWriter.error(new Error(`[Virid HttpSystem] System Parameter Loss:
|
|
12
|
+
Please declare the message type using the Message decorator`));return}let f=t.messageClass??a.messageClass;if(!(f.prototype instanceof H)){h.MessageWriter.error(new Error(`[Virid HttpSystem] Wrong Message Type: ${f.name} is not a derived subclass of HttpRequestMessage!`));return}let c=o(M=>{let E=m.get(M.requestId);if(!E)throw new Error(`[Virid Express HttpSystem] Invalid Request Context: The request context for message ${M.requestId} is missing.`);try{let l=d.map((C,le)=>{if(a&&a.index==le){if(!(M instanceof f)){let Ae=M.constructor.name;throw new Error(`[Virid Express HttpSystem] Type Mismatch: Expected ${f.name}, but received ${Ae}`)}return M}else return rt(C,le,E,x)}),g=n.apply(e,l);return g instanceof Promise?g.then(C=>{A(C,E)}).catch(C=>{throw A(U(),E),C}):A(g,E)}catch(l){throw l instanceof w?A(l,E):A(U(),E),l}},"wrappedSystem"),O={params:d,targetClass:e,methodName:s,originalMethod:n};c.systemContext=O,r.value=c,j.register(f,c,t.priority)}}o(Xe,"HttpSystem");function ze(){return(t,e,s)=>{if(Reflect.hasOwnMetadata(i.BODY,t,e)){h.MessageWriter.error(new Error(`[Virid Express Body] Multiple Body Are Not Allowed: ${e} has multiple @Body() decorators!`));return}let r={index:s};Reflect.defineMetadata(i.BODY,r,t,e)}}o(ze,"Body");function Ke(){return(t,e,s)=>{if(Reflect.hasOwnMetadata(i.HEADERS,t,e)){h.MessageWriter.error(new Error(`[Virid Express Headers] Multiple Header Are Not Allowed: ${e} has multiple @Headers() decorators!`));return}let r={index:s};Reflect.defineMetadata(i.HEADERS,r,t,e)}}o(Ke,"Headers");function Le(){return(t,e,s)=>{if(Reflect.hasOwnMetadata(i.COOKIES,t,e)){h.MessageWriter.error(new Error(`[Virid Express Cookies] Multiple Header Are Not Allowed: ${e} has multiple @Cookies() decorators!`));return}let r={index:s};Reflect.defineMetadata(i.COOKIES,r,t,e)}}o(Le,"Cookies");function Ge(){return(t,e,s)=>{if(Reflect.hasOwnMetadata(i.REQUEST,t,e)){h.MessageWriter.error(new Error(`[Virid Express Req] Multiple Request Objects Are Not Allowed: ${e} has multiple @Req() decorators!`));return}let r={index:s};Reflect.defineMetadata(i.REQUEST,r,t,e)}}o(Ge,"Req");function Je(){return(t,e,s)=>{if(Reflect.hasOwnMetadata(i.RESPONSE,t,e)){h.MessageWriter.error(new Error(`[Virid Express Res] Multiple Response Objects Are Not Allowed: ${e} has multiple @Res() decorators!`));return}let r={index:s};Reflect.defineMetadata(i.RESPONSE,r,t,e)}}o(Je,"Res");function Ze(){return(t,e,s)=>{if(Reflect.hasOwnMetadata(i.CONTEXT,t,e)){h.MessageWriter.error(new Error(`[Virid Express Ctx] Multiple Context Objects Are Not Allowed: ${e} has multiple @Ctx() decorators!`));return}let r={index:s};Reflect.defineMetadata(i.CONTEXT,r,t,e)}}o(Ze,"Ctx");function ke(t,e){return(s,r,n)=>{let a=[...Reflect.getOwnMetadata(i.QUERY,s,r)||[],{index:n,query:t,pipe:e}];Reflect.defineMetadata(i.QUERY,a,s,r)}}o(ke,"Query");function et(t,e){return(s,r,n)=>{let a=[...Reflect.getOwnMetadata(i.PARAMS,s,r)||[],{index:n,key:t,pipe:e}];Reflect.defineMetadata(i.PARAMS,a,s,r)}}o(et,"Params");function tt(t,e,s){let r=Reflect.getOwnMetadata(i.BODY,t,e),n=Reflect.getOwnMetadata(i.HEADERS,t,e),d=Reflect.getOwnMetadata(i.COOKIES,t,e),a=Reflect.getOwnMetadata(i.RESPONSE,t,e),x=Reflect.getOwnMetadata(i.REQUEST,t,e),f=Reflect.getOwnMetadata(i.CONTEXT,t,e),O=(Reflect.getOwnMetadata(i.QUERY,t,e)||[]).map(l=>{if(!l.pipe){let g=s[l.index];l.pipe=Y(g)}return l}),E=(Reflect.getOwnMetadata(i.PARAMS,t,e)||[]).map(l=>{if(!l.pipe){let g=s[l.index];l.pipe=Y(g)}return l});return{bodyMeta:r,headerMeta:n,queryMeta:O,cookiesMeta:d,reqMeta:x,resMeta:a,ctxMeta:f,paramMeta:E}}o(tt,"getHttpMetadata");function rt(t,e,s,r){let{req:n,res:d}=s;if(r.ctxMeta?.index===e)return s;let a=r.paramMeta?.find(c=>c.index===e);if(a){let c=a.key?n.params[a.key]:n.params;return a.pipe&&c!==void 0&&(c=a.pipe(c)),c}if(r.bodyMeta?.index===e)return n.body;if(r.headerMeta?.index===e)return n.headers;if(r.cookiesMeta?.index===e)return pe(n.headers.cookie);if(r.reqMeta?.index===e)return n;if(r.resMeta?.index===e)return d;let x=r.queryMeta?.find(c=>c.index===e);if(x){let c=n.query[x.query];if(c===void 0)throw new Error(`[Virid Express] Missing Query: "${x.query}"`);return x.pipe&&(c=x.pipe(c)),c}let f=Re.get(t);if(!f)throw new Error(`[Virid System] Unknown Inject Type: ${t?.name||"Anonymous Class"} at index ${e}.
|
|
13
|
+
Ensure it is registered in the IOC container or has a proper Http Decorator!`);return f}o(rt,"getHttpSystemArgs");var st={name:"@virid/express",install(t,e){Se(t,e)}};0&&(module.exports={BadRequest,BadRequestResponse,Body,ConflictResponse,Cookies,Created,CreatedResponse,Ctx,CustomResponse,CustomResponseResponse,ExpressPlugin,Forbidden,ForbiddenResponse,Headers,HttpContext,HttpError,HttpRequestMessage,HttpResponse,HttpRoute,HttpSystem,InternalServerError,InternalServerErrorResponse,NoContent,NoContentResponse,NotFound,NotFoundResponse,Ok,OkResponse,Params,ParseBoolPipe,ParseIntPipe,Query,Req,Res,Stream,StreamFile,StreamFileResponse,StreamResponse,Unauthorized,UnauthorizedResponse,UnprocessableEntityResponse,addAutoPipe,getAutoPipe,parseRawCookie});
|
|
40
14
|
//# sourceMappingURL=index.cjs.map
|