@galeh/chuka 1.0.2 → 1.0.3
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/index.d.ts +11 -8
- package/index.js +1 -1
- package/package.json +4 -1
- package/validators/index.d.ts +4 -2
package/index.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import express from 'express';
|
|
1
|
+
import * as express from 'express';
|
|
2
2
|
import { interfaces } from 'inversify';
|
|
3
|
-
import
|
|
3
|
+
import { NextFunction } from 'express';
|
|
4
|
+
import { Request as Request_2 } from 'express';
|
|
5
|
+
import { Response as Response_2 } from 'express';
|
|
6
|
+
import { WebSocket as WebSocket_2 } from 'ws';
|
|
4
7
|
|
|
5
8
|
declare interface ApplicationConfig {
|
|
6
9
|
routes: Array<Route>;
|
|
@@ -36,7 +39,7 @@ declare interface Dependency {
|
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
declare interface ErrorHandler<T> {
|
|
39
|
-
(err: any, req: MergePartial<
|
|
42
|
+
(err: any, req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
declare type EventCallback = {
|
|
@@ -59,7 +62,7 @@ declare type MergePartial<A, B> = {
|
|
|
59
62
|
} & Omit<A, keyof B> & Partial<Omit<B, keyof A>>;
|
|
60
63
|
|
|
61
64
|
export declare interface Middleware<T> {
|
|
62
|
-
(req: MergePartial<
|
|
65
|
+
(req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
declare class MiniController<T> implements MiniControllerInterface<T> {
|
|
@@ -147,9 +150,9 @@ declare type PathParams = string | RegExp | Array<string | RegExp>;
|
|
|
147
150
|
declare type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
|
|
148
151
|
|
|
149
152
|
declare interface RequestHandler<T, P = ParamsDictionary> {
|
|
150
|
-
(req: Merge<
|
|
153
|
+
(req: Merge<Request_2, T & {
|
|
151
154
|
params: P;
|
|
152
|
-
}>, res:
|
|
155
|
+
}>, res: Response_2, next: NextFunction): void;
|
|
153
156
|
}
|
|
154
157
|
|
|
155
158
|
declare type RequestHandlerParams<T> = Middleware<T> | ErrorHandler<T>;
|
|
@@ -192,8 +195,8 @@ declare interface Type<T> extends Function {
|
|
|
192
195
|
new (...args: any[]): T;
|
|
193
196
|
}
|
|
194
197
|
|
|
195
|
-
declare type WSHandler<T> = (ws:
|
|
198
|
+
declare type WSHandler<T> = (ws: WebSocket_2, req: Merge<Request_2, T>) => void;
|
|
196
199
|
|
|
197
|
-
export declare type WSMiddleware<T> = (ws:
|
|
200
|
+
export declare type WSMiddleware<T> = (ws: WebSocket_2, req: MergePartial<Request_2, T>, next: NextFunction) => void;
|
|
198
201
|
|
|
199
202
|
export { }
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={752:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createApp=void 0;const o=i(4);i(236);const s=o.
|
|
1
|
+
(()=>{"use strict";var t={752:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createApp=void 0;const o=i(4);i(236);const s=o.__importStar(i(860)),n=i(455),r=i(120),h=o.__importStar(i(415));function l(t,e){for(const i of t)m(e,i.controller,i.controller),i.children&&l(i.children,e)}function m(t,e,i){t.isBound(e)||t.bind(e).to(i)}function a(t,e,i){t.isBound(e)||t.bind(e).toConstantValue(i)}function d(t,e,i){for(const o of t){const t=e.get(o.controller);i[r.setControllerSymbol](o.path,t),o.children&&d(o.children,e,t)}}e.createApp=function(t){const e=s.default();t.on&&function(t,e){for(const i of e)t.on(i.event,i.callback)}(e,t.on),t.set&&function(t,e){for(const[i,o]of Object.entries(e))t.set(p[i],o)}(e,t.set),h.default(e),t.middlewares&&e.use.apply(e,t.middlewares);const i=new c(e),o=new n.Container;return function(t,e){t.dependencies&&function(t,e){for(const i of t)i.useValue?a(e,i.provide,i.useValue):i.useClass&&m(e,i.provide,i.useClass)}(t.dependencies,e),l(t.routes,e)}(t,o),d(t.routes,o,i),e};class c{constructor(t){this.app=t}[r.setControllerSymbol](t,e){this.app.use(t,e[r.getRouterSymbol]())}}class p{constructor(){this.caseSensitiveRouting="case sensitive routing",this.env="env",this.etag="etag",this.jsonpCallbackName="jsonp callback name",this.jsonEscape="json escape",this.jsonReplacer="json replacer",this.jsonSpaces="json spaces",this.queryParser="query parser",this.strictRouting="strict routing",this.subdomainOffset="subdomain offset",this.trustProxy="trust proxy",this.views="views",this.viewCache="view cache",this.viewEngine="view engine",this.xPoweredBy="x-powered-by"}}},120:(t,e,i)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Controller=e.setControllerSymbol=e.getRouterSymbol=void 0;const o=i(4),s=i(860),n=i(455);e.getRouterSymbol=Symbol(),e.setControllerSymbol=Symbol();let r=class{constructor(){this.router=(0,s.Router)()}[e.setControllerSymbol](t,i){this.router.use(t,i[e.getRouterSymbol]())}[e.getRouterSymbol](){return this.router}middlewareWS(...t){return e=>{this.router.ws.apply(this.router,["/",...t,e])}}middleware(...t){return new h(this.router,t)}};e.Controller=r,e.Controller=r=o.__decorate([(0,n.injectable)()],r);class h{constructor(t,e){this.router=t,this.middlewares=e,this.all=this.methodImplementation("all").bind(this),this.get=this.methodImplementation("get").bind(this),this.post=this.methodImplementation("post").bind(this),this.put=this.methodImplementation("put").bind(this),this.delete=this.methodImplementation("delete").bind(this),this.patch=this.methodImplementation("patch").bind(this),this.options=this.methodImplementation("options").bind(this),this.head=this.methodImplementation("head").bind(this),this.checkout=this.methodImplementation("checkout").bind(this),this.connect=this.methodImplementation("connect").bind(this),this.copy=this.methodImplementation("copy").bind(this),this.lock=this.methodImplementation("lock").bind(this),this.merge=this.methodImplementation("merge").bind(this),this.mkactivity=this.methodImplementation("mkactivity").bind(this),this.mkcol=this.methodImplementation("mkcol").bind(this),this.move=this.methodImplementation("move").bind(this),this["m-search"]=this.methodImplementation("m-search").bind(this),this.notify=this.methodImplementation("notify").bind(this),this.propfind=this.methodImplementation("propfind").bind(this),this.proppatch=this.methodImplementation("proppatch").bind(this),this.purge=this.methodImplementation("purge").bind(this),this.report=this.methodImplementation("report").bind(this),this.search=this.methodImplementation("search").bind(this),this.subscribe=this.methodImplementation("subscribe").bind(this),this.trace=this.methodImplementation("trace").bind(this),this.unlock=this.methodImplementation("unlock").bind(this),this.unsubscribe=this.methodImplementation("unsubscribe").bind(this),this.link=this.methodImplementation("link").bind(this),this.unlink=this.methodImplementation("unlink").bind(this)}methodImplementation(t){return(e,i)=>{this.router[t].apply(this.router,[e,...this.middlewares,(t,e,o)=>{i(t,e,o)}])}}middleware(...t){return new h(this.router,this.middlewares.concat(t))}}},860:t=>{t.exports=require("express")},415:t=>{t.exports=require("express-ws")},455:t=>{t.exports=require("inversify")},236:t=>{t.exports=require("reflect-metadata")},4:t=>{t.exports=require("tslib")}},e={};function i(o){var s=e[o];if(void 0!==s)return s.exports;var n=e[o]={exports:{}};return t[o](n,n.exports,i),n.exports}var o={};(()=>{var t=o;Object.defineProperty(t,"__esModule",{value:!0}),t.Controller=t.createApp=void 0;var e=i(752);Object.defineProperty(t,"createApp",{enumerable:!0,get:function(){return e.createApp}});var s=i(120);Object.defineProperty(t,"Controller",{enumerable:!0,get:function(){return s.Controller}})})(),exports["@galeh/chuka"]=o})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@galeh/chuka",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "simple yet robust wrapper for expressjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chuka",
|
|
@@ -24,5 +24,8 @@
|
|
|
24
24
|
"@types/express": "^4.17.21",
|
|
25
25
|
"@types/express-ws": "^3.0.4",
|
|
26
26
|
"@types/ws": "^8.5.10"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
27
30
|
}
|
|
28
31
|
}
|
package/validators/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { NextFunction } from 'express';
|
|
2
|
+
import { Request as Request_2 } from 'express';
|
|
3
|
+
import { Response as Response_2 } from 'express';
|
|
2
4
|
|
|
3
5
|
export declare function and<T>(...validationFunctions: Array<Validator<T>>): Validator<T>;
|
|
4
6
|
|
|
@@ -30,7 +32,7 @@ declare type MergePartial<A, B> = {
|
|
|
30
32
|
} & Omit<A, keyof B> & Partial<Omit<B, keyof A>>;
|
|
31
33
|
|
|
32
34
|
declare interface Middleware<T> {
|
|
33
|
-
(req: MergePartial<
|
|
35
|
+
(req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
export declare function not<T>(validationFunction: Validator<T>): Validator<T>;
|