@galeh/chuka 1.0.11 → 1.1.0

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.
Files changed (4) hide show
  1. package/README.md +31 -31
  2. package/index.d.ts +14 -14
  3. package/index.js +1 -1
  4. package/package.json +1 -1
package/README.md CHANGED
@@ -44,39 +44,39 @@ app.listen(8080, () => {
44
44
 
45
45
  @injectable()
46
46
  export class CatsController extends Controller {
47
- constructor(@inject('catservice') service: CatsServiceInterface) {
48
- super();
49
-
50
- const intercepted = this.middleware(
51
- createLogger()
52
- );
53
-
54
- intercepted.middleware(
55
- bodyValidator<CatModel>({
56
- name: and(isDefined(), isString()),
57
- country: isNumber(),
58
- age: custom(model => Promise.resolve(!!(model.age && model.age > 2))),
47
+ intercepted = this.middleware(
48
+ createLogger()
49
+ );
50
+
51
+ postCat = this.intercepted.middleware(
52
+ bodyValidator<CatModel>({
53
+ name: and(isDefined(), isString()),
54
+ country: isNumber(),
55
+ age: custom(model => Promise.resolve(!!(model.age && model.age > 2))),
56
+ parents: {
57
+ name: isString(),
59
58
  parents: {
60
- name: isString(),
61
- parents: {
62
- country: isString(),
63
- }
59
+ country: isString(),
64
60
  }
65
- })
66
- ).post('/', async (req, res) => {{
67
- const allcats = await service.add(req.body.name);
68
- res.send(allcats);
69
- }});
70
-
71
- intercepted.get('/', async (req, res) => {{
72
- const allcats = await service.findAll();
73
- res.send(allcats);
74
- }});
75
-
76
- intercepted.get('/:id', async (req, res) => {
77
- const onecat = await service.findOne(+req.params.id);
78
- res.send(onecat);
79
- });
61
+ }
62
+ })
63
+ ).post('/', async (req, res) => {{
64
+ const allcats = await this.service.add(req.body.name);
65
+ res.send(allcats);
66
+ }});
67
+
68
+ getAllCats = this.intercepted.get('/', async (req, res) => {{
69
+ const allcats = await this.service.findAll();
70
+ res.send(allcats);
71
+ }});
72
+
73
+ getCatById = this.intercepted.get('/:id', async (req, res) => {
74
+ const onecat = await this.service.findOne(+req.params.id);
75
+ res.send(onecat);
76
+ });
77
+
78
+ constructor(@inject('catservice') private service: CatsServiceInterface) {
79
+ super();
80
80
  }
81
81
  }
82
82
 
package/index.d.ts CHANGED
@@ -18,16 +18,16 @@ export declare class Controller {
18
18
  constructor();
19
19
  private [setControllerSymbol];
20
20
  private [getRouterSymbol];
21
- protected middlewareWS<M0>(): MiniControllerWS<M0>;
22
- protected middlewareWS<M0>(middleware0: WSMiddleware<M0>): MiniControllerWS<M0>;
23
- protected middlewareWS<M0, M1>(middleware0: WSMiddleware<M0>, middleware1: WSMiddleware<M1>): MiniControllerWS<M0 & M1>;
24
- protected middlewareWS<M0, M1, M2>(middleware0: WSMiddleware<M0>, middleware1: WSMiddleware<M1>, middleware2: WSMiddleware<M2>): MiniControllerWS<M0 & M1 & M2>;
25
- protected middlewareWS<M0, M1, M2, M3>(middleware0: WSMiddleware<M0>, middleware1: WSMiddleware<M1>, middleware2: WSMiddleware<M2>, middleware3: WSMiddleware<M3>): MiniControllerWS<M0 & M1 & M2 & M3>;
26
- protected middleware<M0>(): MiniController<M0>;
27
- protected middleware<M0>(middleware0: RequestHandlerParams<M0>): MiniController<M0>;
28
- protected middleware<M0, M1>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>): MiniController<M0 & M1>;
29
- protected middleware<M0, M1, M2>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>): MiniController<M0 & M1 & M2>;
30
- protected middleware<M0, M1, M2, M3>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>, middleware3: RequestHandlerParams<M3>): MiniController<M0 & M1 & M2 & M3>;
21
+ protected useWS<M0>(): MiniControllerWS<M0>;
22
+ protected useWS<M0>(middleware0: WSMiddleware<M0>): MiniControllerWS<M0>;
23
+ protected useWS<M0, M1>(middleware0: WSMiddleware<M0>, middleware1: WSMiddleware<M1>): MiniControllerWS<M0 & M1>;
24
+ protected useWS<M0, M1, M2>(middleware0: WSMiddleware<M0>, middleware1: WSMiddleware<M1>, middleware2: WSMiddleware<M2>): MiniControllerWS<M0 & M1 & M2>;
25
+ protected useWS<M0, M1, M2, M3>(middleware0: WSMiddleware<M0>, middleware1: WSMiddleware<M1>, middleware2: WSMiddleware<M2>, middleware3: WSMiddleware<M3>): MiniControllerWS<M0 & M1 & M2 & M3>;
26
+ protected use<M0>(): MiniController<M0>;
27
+ protected use<M0>(middleware0: RequestHandlerParams<M0>): MiniController<M0>;
28
+ protected use<M0, M1>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>): MiniController<M0 & M1>;
29
+ protected use<M0, M1, M2>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>): MiniController<M0 & M1 & M2>;
30
+ protected use<M0, M1, M2, M3>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>, middleware3: RequestHandlerParams<M3>): MiniController<M0 & M1 & M2 & M3>;
31
31
  }
32
32
 
33
33
  export declare function createApp(config: ApplicationConfig): express.Application;
@@ -99,10 +99,10 @@ declare class MiniController<T> implements MiniControllerInterface<T> {
99
99
  link: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
100
100
  unlink: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
101
101
  private methodImplementation;
102
- middleware<M0>(middleware0: RequestHandlerParams<M0>): MiniController<Merge<T, M0>>;
103
- middleware<M0, M1>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>): MiniController<Merge<T, M0 & M1>>;
104
- middleware<M0, M1, M2>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>): MiniController<Merge<T, M0 & M1 & M2>>;
105
- middleware<M0, M1, M2, M3>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>, middleware3: RequestHandlerParams<M3>): MiniController<Merge<T, M0 & M1 & M2 & M3>>;
102
+ use<M0>(middleware0: RequestHandlerParams<M0>): MiniController<Merge<T, M0>>;
103
+ use<M0, M1>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>): MiniController<Merge<T, M0 & M1>>;
104
+ use<M0, M1, M2>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>): MiniController<Merge<T, M0 & M1 & M2>>;
105
+ use<M0, M1, M2, M3>(middleware0: RequestHandlerParams<M0>, middleware1: RequestHandlerParams<M1>, middleware2: RequestHandlerParams<M2>, middleware3: RequestHandlerParams<M3>): MiniController<Merge<T, M0 & M1 & M2 & M3>>;
106
106
  }
107
107
 
108
108
  declare interface MiniControllerInterface<T> {
package/index.js CHANGED
@@ -24,7 +24,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
24
24
  \***************************/
25
25
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
26
26
 
27
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Controller: () => (/* binding */ Controller),\n/* harmony export */ getRouterSymbol: () => (/* binding */ getRouterSymbol),\n/* harmony export */ setControllerSymbol: () => (/* binding */ setControllerSymbol)\n/* harmony export */ });\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ \"tslib\");\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tslib__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! express */ \"express\");\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(express__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var inversify__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! inversify */ \"inversify\");\n/* harmony import */ var inversify__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(inversify__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\nconst getRouterSymbol = Symbol();\nconst setControllerSymbol = Symbol();\nlet Controller = class Controller {\n constructor() {\n this.router = (0,express__WEBPACK_IMPORTED_MODULE_1__.Router)();\n }\n [setControllerSymbol](path, subrouter) {\n this.router.use(path, subrouter[getRouterSymbol]());\n }\n [getRouterSymbol]() {\n return this.router;\n }\n middlewareWS(...middlewares) {\n return (handler) => {\n this.router.ws.apply(this.router, ['/', ...middlewares, handler]);\n };\n }\n middleware(...middlewares) {\n return new MiniController(this.router, middlewares);\n }\n};\nController = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([\n (0,inversify__WEBPACK_IMPORTED_MODULE_2__.injectable)()\n], Controller);\n\nclass MiniController {\n constructor(router, middlewares) {\n this.router = router;\n this.middlewares = middlewares;\n this.all = this.methodImplementation('all').bind(this);\n this.get = this.methodImplementation('get').bind(this);\n this.post = this.methodImplementation('post').bind(this);\n this.put = this.methodImplementation('put').bind(this);\n this.delete = this.methodImplementation('delete').bind(this);\n this.patch = this.methodImplementation('patch').bind(this);\n this.options = this.methodImplementation('options').bind(this);\n this.head = this.methodImplementation('head').bind(this);\n this.checkout = this.methodImplementation('checkout').bind(this);\n this.connect = this.methodImplementation('connect').bind(this);\n this.copy = this.methodImplementation('copy').bind(this);\n this.lock = this.methodImplementation('lock').bind(this);\n this.merge = this.methodImplementation('merge').bind(this);\n this.mkactivity = this.methodImplementation('mkactivity').bind(this);\n this.mkcol = this.methodImplementation('mkcol').bind(this);\n this.move = this.methodImplementation('move').bind(this);\n this['m-search'] = this.methodImplementation('m-search').bind(this);\n this.notify = this.methodImplementation('notify').bind(this);\n this.propfind = this.methodImplementation('propfind').bind(this);\n this.proppatch = this.methodImplementation('proppatch').bind(this);\n this.purge = this.methodImplementation('purge').bind(this);\n this.report = this.methodImplementation('report').bind(this);\n this.search = this.methodImplementation('search').bind(this);\n this.subscribe = this.methodImplementation('subscribe').bind(this);\n this.trace = this.methodImplementation('trace').bind(this);\n this.unlock = this.methodImplementation('unlock').bind(this);\n this.unsubscribe = this.methodImplementation('unsubscribe').bind(this);\n this.link = this.methodImplementation('link').bind(this);\n this.unlink = this.methodImplementation('unlink').bind(this);\n }\n methodImplementation(methodName) {\n return (path, handler) => {\n this.router[methodName].apply(this.router, [\n path,\n ...this.middlewares,\n (req, res, next) => {\n handler(req, res, next);\n }\n ]);\n };\n }\n middleware(...middlewares) {\n return new MiniController(this.router, this.middlewares.concat(middlewares));\n }\n}\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/controller.ts?");
27
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Controller: () => (/* binding */ Controller),\n/* harmony export */ getRouterSymbol: () => (/* binding */ getRouterSymbol),\n/* harmony export */ setControllerSymbol: () => (/* binding */ setControllerSymbol)\n/* harmony export */ });\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ \"tslib\");\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(tslib__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! express */ \"express\");\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(express__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var inversify__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! inversify */ \"inversify\");\n/* harmony import */ var inversify__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(inversify__WEBPACK_IMPORTED_MODULE_2__);\n\n\n\nconst getRouterSymbol = Symbol();\nconst setControllerSymbol = Symbol();\nlet Controller = class Controller {\n constructor() {\n this.router = (0,express__WEBPACK_IMPORTED_MODULE_1__.Router)();\n }\n [setControllerSymbol](path, subrouter) {\n this.router.use(path, subrouter[getRouterSymbol]());\n }\n [getRouterSymbol]() {\n return this.router;\n }\n useWS(...middlewares) {\n return (handler) => {\n this.router.ws.apply(this.router, ['/', ...middlewares, handler]);\n };\n }\n use(...middlewares) {\n return new MiniController(this.router, middlewares);\n }\n};\nController = (0,tslib__WEBPACK_IMPORTED_MODULE_0__.__decorate)([\n (0,inversify__WEBPACK_IMPORTED_MODULE_2__.injectable)()\n], Controller);\n\nclass MiniController {\n constructor(router, middlewares) {\n this.router = router;\n this.middlewares = middlewares;\n this.all = this.methodImplementation('all').bind(this);\n this.get = this.methodImplementation('get').bind(this);\n this.post = this.methodImplementation('post').bind(this);\n this.put = this.methodImplementation('put').bind(this);\n this.delete = this.methodImplementation('delete').bind(this);\n this.patch = this.methodImplementation('patch').bind(this);\n this.options = this.methodImplementation('options').bind(this);\n this.head = this.methodImplementation('head').bind(this);\n this.checkout = this.methodImplementation('checkout').bind(this);\n this.connect = this.methodImplementation('connect').bind(this);\n this.copy = this.methodImplementation('copy').bind(this);\n this.lock = this.methodImplementation('lock').bind(this);\n this.merge = this.methodImplementation('merge').bind(this);\n this.mkactivity = this.methodImplementation('mkactivity').bind(this);\n this.mkcol = this.methodImplementation('mkcol').bind(this);\n this.move = this.methodImplementation('move').bind(this);\n this['m-search'] = this.methodImplementation('m-search').bind(this);\n this.notify = this.methodImplementation('notify').bind(this);\n this.propfind = this.methodImplementation('propfind').bind(this);\n this.proppatch = this.methodImplementation('proppatch').bind(this);\n this.purge = this.methodImplementation('purge').bind(this);\n this.report = this.methodImplementation('report').bind(this);\n this.search = this.methodImplementation('search').bind(this);\n this.subscribe = this.methodImplementation('subscribe').bind(this);\n this.trace = this.methodImplementation('trace').bind(this);\n this.unlock = this.methodImplementation('unlock').bind(this);\n this.unsubscribe = this.methodImplementation('unsubscribe').bind(this);\n this.link = this.methodImplementation('link').bind(this);\n this.unlink = this.methodImplementation('unlink').bind(this);\n }\n methodImplementation(methodName) {\n return (path, handler) => {\n this.router[methodName].apply(this.router, [\n path,\n ...this.middlewares,\n (req, res, next) => {\n handler(req, res, next);\n }\n ]);\n };\n }\n use(...middlewares) {\n return new MiniController(this.router, this.middlewares.concat(middlewares));\n }\n}\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/controller.ts?");
28
28
 
29
29
  /***/ }),
30
30
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galeh/chuka",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "description": "simple yet robust wrapper for expressjs",
5
5
  "keywords": [
6
6
  "chuka",