@galeh/chuka 1.0.1 → 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 +14 -10
- package/index.js +1 -1
- package/package.json +8 -2
- package/validators/index.d.ts +4 -3
package/index.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import express from 'express';
|
|
1
|
+
import * as express from 'express';
|
|
3
2
|
import { interfaces } from 'inversify';
|
|
4
|
-
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';
|
|
5
7
|
|
|
6
8
|
declare interface ApplicationConfig {
|
|
7
9
|
routes: Array<Route>;
|
|
@@ -37,7 +39,7 @@ declare interface Dependency {
|
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
declare interface ErrorHandler<T> {
|
|
40
|
-
(err: any, req: MergePartial<
|
|
42
|
+
(err: any, req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
declare type EventCallback = {
|
|
@@ -60,7 +62,7 @@ declare type MergePartial<A, B> = {
|
|
|
60
62
|
} & Omit<A, keyof B> & Partial<Omit<B, keyof A>>;
|
|
61
63
|
|
|
62
64
|
export declare interface Middleware<T> {
|
|
63
|
-
(req: MergePartial<
|
|
65
|
+
(req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
68
|
declare class MiniController<T> implements MiniControllerInterface<T> {
|
|
@@ -143,18 +145,20 @@ declare interface ParamsDictionary {
|
|
|
143
145
|
[key: string]: string;
|
|
144
146
|
}
|
|
145
147
|
|
|
148
|
+
declare type PathParams = string | RegExp | Array<string | RegExp>;
|
|
149
|
+
|
|
146
150
|
declare type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
|
|
147
151
|
|
|
148
152
|
declare interface RequestHandler<T, P = ParamsDictionary> {
|
|
149
|
-
(req: Merge<
|
|
153
|
+
(req: Merge<Request_2, T & {
|
|
150
154
|
params: P;
|
|
151
|
-
}>, res:
|
|
155
|
+
}>, res: Response_2, next: NextFunction): void;
|
|
152
156
|
}
|
|
153
157
|
|
|
154
158
|
declare type RequestHandlerParams<T> = Middleware<T> | ErrorHandler<T>;
|
|
155
159
|
|
|
156
160
|
declare interface Route {
|
|
157
|
-
path:
|
|
161
|
+
path: PathParams;
|
|
158
162
|
controller: Type<Controller>;
|
|
159
163
|
children?: Array<Route>;
|
|
160
164
|
}
|
|
@@ -191,8 +195,8 @@ declare interface Type<T> extends Function {
|
|
|
191
195
|
new (...args: any[]): T;
|
|
192
196
|
}
|
|
193
197
|
|
|
194
|
-
declare type WSHandler<T> = (ws:
|
|
198
|
+
declare type WSHandler<T> = (ws: WebSocket_2, req: Merge<Request_2, T>) => void;
|
|
195
199
|
|
|
196
|
-
export declare type WSMiddleware<T> = (ws:
|
|
200
|
+
export declare type WSMiddleware<T> = (ws: WebSocket_2, req: MergePartial<Request_2, T>, next: NextFunction) => void;
|
|
197
201
|
|
|
198
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",
|
|
@@ -20,6 +20,12 @@
|
|
|
20
20
|
"express-ws": "^5.0.2",
|
|
21
21
|
"inversify": "^6.0.2",
|
|
22
22
|
"reflect-metadata": "^0.2.1",
|
|
23
|
-
"tslib": "^2.6.2"
|
|
23
|
+
"tslib": "^2.6.2",
|
|
24
|
+
"@types/express": "^4.17.21",
|
|
25
|
+
"@types/express-ws": "^3.0.4",
|
|
26
|
+
"@types/ws": "^8.5.10"
|
|
27
|
+
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
24
30
|
}
|
|
25
31
|
}
|
package/validators/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { NextFunction } from 'express';
|
|
2
|
+
import { Request as Request_2 } from 'express';
|
|
3
|
+
import { Response as Response_2 } from 'express';
|
|
3
4
|
|
|
4
5
|
export declare function and<T>(...validationFunctions: Array<Validator<T>>): Validator<T>;
|
|
5
6
|
|
|
@@ -31,7 +32,7 @@ declare type MergePartial<A, B> = {
|
|
|
31
32
|
} & Omit<A, keyof B> & Partial<Omit<B, keyof A>>;
|
|
32
33
|
|
|
33
34
|
declare interface Middleware<T> {
|
|
34
|
-
(req: MergePartial<
|
|
35
|
+
(req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export declare function not<T>(validationFunction: Validator<T>): Validator<T>;
|