@galeh/chuka 1.1.4 → 1.1.5

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 (3) hide show
  1. package/README.md +95 -50
  2. package/index.js +17 -58
  3. package/package.json +3 -2
package/README.md CHANGED
@@ -16,71 +16,116 @@
16
16
  npm install @galeh/chuka
17
17
  ```
18
18
  ```typescript
19
- // main.ts
20
- import { createApp, json } from '@galeh/chuka';
21
- import { CatsController, CatsService } from './your-modules'; // Customize based on your project structure
19
+ import { createApp, Controller, injectable, json, bodyValidator, and, isDefined, isString, isNumber, custom, inject } from '@galeh/chuka';
20
+
21
+ @injectable()
22
+ class CatsService implements CatsServiceInterface {
23
+ private cats: CatsModel[] = [
24
+ {
25
+ age: 1,
26
+ country: 'USA',
27
+ name: 'Tom',
28
+ parents: [
29
+ {
30
+ age: 2,
31
+ country: 'Cuba',
32
+ name: 'Daddy',
33
+ parents: []
34
+ },
35
+ {
36
+ age: 2,
37
+ country: 'China',
38
+ name: 'Mommy',
39
+ parents: []
40
+ }
41
+ ]
42
+ }
43
+ ]
44
+
45
+ findAll(): Promise<CatsModel[]> {
46
+ return Promise.resolve(this.cats);
47
+ }
48
+
49
+ findOne(name: string): Promise<CatsModel | null> {
50
+ return Promise.resolve(this.cats.filter(cat => cat.name === name)[0] || null);
51
+ }
52
+
53
+ add(cat: CatsModel): Promise<void> {
54
+ this.cats.push(cat);
55
+ return Promise.resolve();
56
+ }
57
+ }
58
+
59
+ @injectable()
60
+ class CatsController extends Controller {
61
+ private intercepted = this.use(
62
+ );
63
+
64
+ postCat = this.intercepted.use(
65
+ bodyValidator<CatsModel>({
66
+ name: and(isDefined(), isString()),
67
+ country: isNumber(),
68
+ age: custom(model => Promise.resolve(!!(model.age && model.age > 2))),
69
+ parents: custom(model => Array.isArray(model.parents))
70
+ })
71
+ ).post('/', async (req, res) => {
72
+ {
73
+ const allcats = await this.service.add(req.body);
74
+ res.send(allcats);
75
+ }
76
+ });
77
+
78
+ getAllCats = this.intercepted.get('/', async (req, res) => {
79
+ {
80
+ const allcats = await this.service.findAll();
81
+ res.send(allcats);
82
+ }
83
+ });
84
+
85
+ getCatByName = this.intercepted.get('/:name', async (req, res) => {
86
+ const onecat = await this.service.findOne(req.params.name);
87
+ res.send(onecat);
88
+ });
89
+
90
+ constructor(@inject('catservice') private service: CatsServiceInterface) {
91
+ super();
92
+ }
93
+ }
22
94
 
23
95
  const app = createApp({
24
- dependencies: [
25
- { provide: 'catservice', useClass: CatsService },
26
- // Add more dependencies as needed
27
- ],
28
- routes: [{ path: '/cats', controller: CatsController }],
29
- middlewares: [json()],
96
+ dependencies: [
97
+ { provide: 'catservice', useClass: CatsService },
98
+ // Add more dependencies as needed
99
+ ],
100
+ routes: [{ path: '/cats', controller: CatsController }],
101
+ middlewares: [json()],
30
102
  });
31
103
 
32
104
  app.use((error: any, req: any, res: any, next: any) => {
33
- res.status(400).json(error);
105
+ res.status(400).json(error);
34
106
  });
35
107
 
36
108
  app.listen(8080, () => {
37
- console.log('🚀 Running @galeh/chuka application on port 8080!');
109
+ console.log('🚀 Running @galeh/chuka application on port 8080!');
38
110
  });
39
111
 
40
- ```
41
112
 
42
- ```typescript
43
- // a typical controller
113
+ interface CatsServiceInterface {
114
+ add(cat: CatsModel): Promise<void>;
115
+ findAll(): Promise<CatsModel[]>;
116
+ findOne(name: string): Promise<CatsModel | null>;
117
+ }
44
118
 
45
- @injectable()
46
- export class CatsController extends Controller {
47
- intercepted = this.use(
48
- createLogger()
49
- );
50
-
51
- postCat = this.intercepted.use(
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(),
58
- parents: {
59
- country: isString(),
60
- }
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
- }
119
+ interface CatsModel {
120
+ name: string;
121
+ country: string;
122
+ age: number;
123
+ parents: CatsModel[];
81
124
  }
82
125
 
83
126
  ```
127
+
128
+
84
129
  Explore the possibilities and experience a new level of Express.js development with [@galeh/chuka](https://www.npmjs.com/package/@galeh/chuka). 🌟
85
130
 
86
131
 
package/index.js CHANGED
@@ -12,9 +12,9 @@
12
12
  /*!********************!*\
13
13
  !*** ./src/app.ts ***!
14
14
  \********************/
15
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
15
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
16
16
 
17
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ createApp: () => (/* binding */ createApp)\n/* harmony export */ });\n/* harmony import */ var reflect_metadata__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! reflect-metadata */ \"reflect-metadata\");\n/* harmony import */ var reflect_metadata__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(reflect_metadata__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/* harmony import */ var _controller__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./controller */ \"./src/controller.ts\");\n/* harmony import */ var express_ws__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! express-ws */ \"express-ws\");\n/* harmony import */ var express_ws__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(express_ws__WEBPACK_IMPORTED_MODULE_3__);\n\n\n\n\n\nfunction createApp(config) {\n const app = express__WEBPACK_IMPORTED_MODULE_1___default()();\n if (config.on) {\n setEventCallbacks(app, config.on);\n }\n if (config.set) {\n applySettings(app, config.set);\n }\n express_ws__WEBPACK_IMPORTED_MODULE_3___default()(app);\n if (config.middlewares) {\n app.use.apply(app, config.middlewares);\n }\n const controllerEmulator = new ControllerEmulator(app);\n const container = new inversify__WEBPACK_IMPORTED_MODULE_2__.Container();\n initAllDependencies(config, container);\n initControllers(config.routes, container, controllerEmulator);\n return app;\n}\nfunction setEventCallbacks(app, settings) {\n for (const setting of settings) {\n app.on(setting.event, setting.callback);\n }\n}\nfunction applySettings(app, settings) {\n for (const [key, value] of Object.entries(settings)) {\n // @ts-ignore\n app.set(SettingsEnum[key], value);\n }\n}\nfunction initAllDependencies(config, container) {\n if (config.dependencies) {\n initDependencies(config.dependencies, container);\n }\n initControllersAsDependency(config.routes, container);\n}\nfunction initDependencies(dependencies, container) {\n for (const dep of dependencies) {\n if (dep.useValue) {\n bindValue(container, dep.provide, dep.useValue);\n continue;\n }\n if (dep.useClass) {\n bindClass(container, dep.provide, dep.useClass);\n continue;\n }\n }\n}\nfunction initControllersAsDependency(routes, container) {\n for (const route of routes) {\n bindClass(container, route.controller, route.controller);\n if (route.children) {\n initControllersAsDependency(route.children, container);\n }\n }\n}\nfunction bindClass(container, token, classtype) {\n if (!container.isBound(token)) {\n container.bind(token).to(classtype);\n }\n}\nfunction bindValue(container, token, value) {\n if (!container.isBound(token)) {\n container.bind(token).toConstantValue(value);\n }\n}\nfunction bindFactory(container, token, factory) {\n if (!container.isBound(token)) {\n container.bind(token).toFactory(factory);\n }\n}\nfunction initControllers(routes, container, app) {\n for (const route of routes) {\n const controller = container.get(route.controller);\n app[_controller__WEBPACK_IMPORTED_MODULE_4__.setControllerSymbol](route.path, controller);\n if (route.children) {\n initControllers(route.children, container, controller);\n }\n }\n}\nclass ControllerEmulator {\n constructor(app) {\n this.app = app;\n }\n [_controller__WEBPACK_IMPORTED_MODULE_4__.setControllerSymbol](path, subrouter) {\n this.app.use(path, subrouter[_controller__WEBPACK_IMPORTED_MODULE_4__.getRouterSymbol]());\n }\n}\nclass SettingsEnum {\n constructor() {\n this.caseSensitiveRouting = 'case sensitive routing';\n this.env = 'env';\n this.etag = 'etag';\n this.jsonpCallbackName = 'jsonp callback name';\n this.jsonEscape = 'json escape';\n this.jsonReplacer = 'json replacer';\n this.jsonSpaces = 'json spaces';\n this.queryParser = 'query parser';\n this.strictRouting = 'strict routing';\n this.subdomainOffset = 'subdomain offset';\n this.trustProxy = 'trust proxy';\n this.views = 'views';\n this.viewCache = 'view cache';\n this.viewEngine = 'view engine';\n this.xPoweredBy = 'x-powered-by';\n }\n}\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/app.ts?");
17
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.createApp = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"tslib\");\n__webpack_require__(/*! reflect-metadata */ \"reflect-metadata\");\nconst express = tslib_1.__importStar(__webpack_require__(/*! express */ \"express\"));\nconst inversify_1 = __webpack_require__(/*! inversify */ \"inversify\");\nconst controller_1 = __webpack_require__(/*! ./controller */ \"./src/controller.ts\");\nconst ws = tslib_1.__importStar(__webpack_require__(/*! express-ws */ \"express-ws\"));\nfunction createApp(config) {\n const app = express.default();\n if (config.on) {\n setEventCallbacks(app, config.on);\n }\n if (config.set) {\n applySettings(app, config.set);\n }\n ws.default(app);\n if (config.middlewares) {\n app.use.apply(app, config.middlewares);\n }\n const controllerEmulator = new ControllerEmulator(app);\n const container = new inversify_1.Container();\n initAllDependencies(config, container);\n initControllers(config.routes, container, controllerEmulator);\n return app;\n}\nexports.createApp = createApp;\nfunction setEventCallbacks(app, settings) {\n for (const setting of settings) {\n app.on(setting.event, setting.callback);\n }\n}\nfunction applySettings(app, settings) {\n for (const [key, value] of Object.entries(settings)) {\n // @ts-ignore\n app.set(SettingsEnum[key], value);\n }\n}\nfunction initAllDependencies(config, container) {\n if (config.dependencies) {\n initDependencies(config.dependencies, container);\n }\n initControllersAsDependency(config.routes, container);\n}\nfunction initDependencies(dependencies, container) {\n for (const dep of dependencies) {\n if (dep.useValue) {\n bindValue(container, dep.provide, dep.useValue);\n continue;\n }\n if (dep.useClass) {\n bindClass(container, dep.provide, dep.useClass);\n continue;\n }\n }\n}\nfunction initControllersAsDependency(routes, container) {\n for (const route of routes) {\n bindClass(container, route.controller, route.controller);\n if (route.children) {\n initControllersAsDependency(route.children, container);\n }\n }\n}\nfunction bindClass(container, token, classtype) {\n if (!container.isBound(token)) {\n container.bind(token).to(classtype);\n }\n}\nfunction bindValue(container, token, value) {\n if (!container.isBound(token)) {\n container.bind(token).toConstantValue(value);\n }\n}\nfunction bindFactory(container, token, factory) {\n if (!container.isBound(token)) {\n container.bind(token).toFactory(factory);\n }\n}\nfunction initControllers(routes, container, app) {\n for (const route of routes) {\n const controller = container.get(route.controller);\n app[controller_1.setControllerSymbol](route.path, controller);\n if (route.children) {\n initControllers(route.children, container, controller);\n }\n }\n}\nclass ControllerEmulator {\n constructor(app) {\n this.app = app;\n }\n [controller_1.setControllerSymbol](path, subrouter) {\n this.app.use(path, subrouter[controller_1.getRouterSymbol]());\n }\n}\nclass SettingsEnum {\n constructor() {\n this.caseSensitiveRouting = 'case sensitive routing';\n this.env = 'env';\n this.etag = 'etag';\n this.jsonpCallbackName = 'jsonp callback name';\n this.jsonEscape = 'json escape';\n this.jsonReplacer = 'json replacer';\n this.jsonSpaces = 'json spaces';\n this.queryParser = 'query parser';\n this.strictRouting = 'strict routing';\n this.subdomainOffset = 'subdomain offset';\n this.trustProxy = 'trust proxy';\n this.views = 'views';\n this.viewCache = 'view cache';\n this.viewEngine = 'view engine';\n this.xPoweredBy = 'x-powered-by';\n }\n}\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/app.ts?");
18
18
 
19
19
  /***/ }),
20
20
 
@@ -22,9 +22,9 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
22
22
  /*!***************************!*\
23
23
  !*** ./src/controller.ts ***!
24
24
  \***************************/
25
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
25
+ /***/ ((__unused_webpack_module, 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 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?");
27
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Controller = exports.setControllerSymbol = exports.getRouterSymbol = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"tslib\");\nconst express_1 = __webpack_require__(/*! express */ \"express\");\nconst inversify_1 = __webpack_require__(/*! inversify */ \"inversify\");\nexports.getRouterSymbol = Symbol();\nexports.setControllerSymbol = Symbol();\nlet Controller = class Controller {\n constructor() {\n this.router = (0, express_1.Router)();\n }\n [exports.setControllerSymbol](path, subrouter) {\n this.router.use(path, subrouter[exports.getRouterSymbol]());\n }\n [exports.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};\nexports.Controller = Controller;\nexports.Controller = Controller = tslib_1.__decorate([\n (0, inversify_1.injectable)()\n], Controller);\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
 
@@ -32,9 +32,9 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
32
32
  /*!*********************************!*\
33
33
  !*** ./src/decorators/index.ts ***!
34
34
  \*********************************/
35
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
35
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
36
36
 
37
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ inject: () => (/* reexport safe */ inversify__WEBPACK_IMPORTED_MODULE_0__.inject),\n/* harmony export */ injectable: () => (/* reexport safe */ inversify__WEBPACK_IMPORTED_MODULE_0__.injectable)\n/* harmony export */ });\n/* harmony import */ var inversify__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! inversify */ \"inversify\");\n/* harmony import */ var inversify__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(inversify__WEBPACK_IMPORTED_MODULE_0__);\n\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/decorators/index.ts?");
37
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.injectable = exports.inject = void 0;\nvar inversify_1 = __webpack_require__(/*! inversify */ \"inversify\");\nObject.defineProperty(exports, \"inject\", ({ enumerable: true, get: function () { return inversify_1.inject; } }));\nObject.defineProperty(exports, \"injectable\", ({ enumerable: true, get: function () { return inversify_1.injectable; } }));\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/decorators/index.ts?");
38
38
 
39
39
  /***/ }),
40
40
 
@@ -42,9 +42,9 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
42
42
  /*!**********************!*\
43
43
  !*** ./src/index.ts ***!
44
44
  \**********************/
45
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
45
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
46
46
 
47
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ Controller: () => (/* reexport safe */ _controller__WEBPACK_IMPORTED_MODULE_1__.Controller),\n/* harmony export */ and: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.and),\n/* harmony export */ bodyValidator: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.bodyValidator),\n/* harmony export */ createApp: () => (/* reexport safe */ _app__WEBPACK_IMPORTED_MODULE_0__.createApp),\n/* harmony export */ custom: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.custom),\n/* harmony export */ inject: () => (/* reexport safe */ _decorators__WEBPACK_IMPORTED_MODULE_2__.inject),\n/* harmony export */ injectable: () => (/* reexport safe */ _decorators__WEBPACK_IMPORTED_MODULE_2__.injectable),\n/* harmony export */ isDefined: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.isDefined),\n/* harmony export */ isNull: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.isNull),\n/* harmony export */ isNumber: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.isNumber),\n/* harmony export */ isString: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.isString),\n/* harmony export */ isUndefined: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.isUndefined),\n/* harmony export */ json: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_3__.json),\n/* harmony export */ not: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.not),\n/* harmony export */ notNull: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.notNull),\n/* harmony export */ or: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.or),\n/* harmony export */ query: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_3__.query),\n/* harmony export */ raw: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_3__.raw),\n/* harmony export */ \"static\": () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_3__[\"static\"]),\n/* harmony export */ text: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_3__.text),\n/* harmony export */ urlencoded: () => (/* reexport safe */ _middlewares__WEBPACK_IMPORTED_MODULE_3__.urlencoded),\n/* harmony export */ validator: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_4__.validator)\n/* harmony export */ });\n/* harmony import */ var _app__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./app */ \"./src/app.ts\");\n/* harmony import */ var _controller__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./controller */ \"./src/controller.ts\");\n/* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./decorators */ \"./src/decorators/index.ts\");\n/* harmony import */ var _middlewares__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./middlewares */ \"./src/middlewares/index.ts\");\n/* harmony import */ var _validators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./validators */ \"./src/validators/index.ts\");\n\n\n\n\n\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/index.ts?");
47
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.Controller = exports.createApp = void 0;\nconst tslib_1 = __webpack_require__(/*! tslib */ \"tslib\");\nvar app_1 = __webpack_require__(/*! ./app */ \"./src/app.ts\");\nObject.defineProperty(exports, \"createApp\", ({ enumerable: true, get: function () { return app_1.createApp; } }));\nvar controller_1 = __webpack_require__(/*! ./controller */ \"./src/controller.ts\");\nObject.defineProperty(exports, \"Controller\", ({ enumerable: true, get: function () { return controller_1.Controller; } }));\ntslib_1.__exportStar(__webpack_require__(/*! ./decorators */ \"./src/decorators/index.ts\"), exports);\ntslib_1.__exportStar(__webpack_require__(/*! ./middlewares */ \"./src/middlewares/index.ts\"), exports);\ntslib_1.__exportStar(__webpack_require__(/*! ./validators */ \"./src/validators/index.ts\"), exports);\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/index.ts?");
48
48
 
49
49
  /***/ }),
50
50
 
@@ -52,9 +52,9 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
52
52
  /*!**********************************!*\
53
53
  !*** ./src/middlewares/index.ts ***!
54
54
  \**********************************/
55
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
55
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
56
56
 
57
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ json: () => (/* reexport safe */ express__WEBPACK_IMPORTED_MODULE_0__.json),\n/* harmony export */ query: () => (/* reexport safe */ express__WEBPACK_IMPORTED_MODULE_0__.query),\n/* harmony export */ raw: () => (/* reexport safe */ express__WEBPACK_IMPORTED_MODULE_0__.raw),\n/* harmony export */ \"static\": () => (/* reexport safe */ express__WEBPACK_IMPORTED_MODULE_0__[\"static\"]),\n/* harmony export */ text: () => (/* reexport safe */ express__WEBPACK_IMPORTED_MODULE_0__.text),\n/* harmony export */ urlencoded: () => (/* reexport safe */ express__WEBPACK_IMPORTED_MODULE_0__.urlencoded)\n/* harmony export */ });\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! express */ \"express\");\n/* harmony import */ var express__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(express__WEBPACK_IMPORTED_MODULE_0__);\n\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/middlewares/index.ts?");
57
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.text = exports.raw = exports.query = exports.urlencoded = exports[\"static\"] = exports.json = void 0;\nvar express_1 = __webpack_require__(/*! express */ \"express\");\nObject.defineProperty(exports, \"json\", ({ enumerable: true, get: function () { return express_1.json; } }));\nObject.defineProperty(exports, \"static\", ({ enumerable: true, get: function () { return express_1.static; } }));\nObject.defineProperty(exports, \"urlencoded\", ({ enumerable: true, get: function () { return express_1.urlencoded; } }));\nObject.defineProperty(exports, \"query\", ({ enumerable: true, get: function () { return express_1.query; } }));\nObject.defineProperty(exports, \"raw\", ({ enumerable: true, get: function () { return express_1.raw; } }));\nObject.defineProperty(exports, \"text\", ({ enumerable: true, get: function () { return express_1.text; } }));\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/middlewares/index.ts?");
58
58
 
59
59
  /***/ }),
60
60
 
@@ -62,9 +62,9 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
62
62
  /*!******************************************!*\
63
63
  !*** ./src/validators/body-validator.ts ***!
64
64
  \******************************************/
65
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
65
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
66
66
 
67
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ bodyValidator: () => (/* binding */ bodyValidator)\n/* harmony export */ });\n/* harmony import */ var ___WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! . */ \"./src/validators/validators.ts\");\n\nfunction bodyValidator(validationLogic) {\n return (req, res, next) => {\n (0,___WEBPACK_IMPORTED_MODULE_0__.validator)(validationLogic, 'body')(req, res, next);\n };\n}\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/validators/body-validator.ts?");
67
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.bodyValidator = void 0;\nconst _1 = __webpack_require__(/*! . */ \"./src/validators/index.ts\");\nfunction bodyValidator(validationLogic) {\n return (req, res, next) => {\n (0, _1.validator)(validationLogic, 'body')(req, res, next);\n };\n}\nexports.bodyValidator = bodyValidator;\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/validators/body-validator.ts?");
68
68
 
69
69
  /***/ }),
70
70
 
@@ -72,9 +72,9 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
72
72
  /*!*********************************!*\
73
73
  !*** ./src/validators/index.ts ***!
74
74
  \*********************************/
75
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
75
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
76
76
 
77
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ and: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.and),\n/* harmony export */ bodyValidator: () => (/* reexport safe */ _body_validator__WEBPACK_IMPORTED_MODULE_1__.bodyValidator),\n/* harmony export */ custom: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.custom),\n/* harmony export */ isDefined: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.isDefined),\n/* harmony export */ isNull: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.isNull),\n/* harmony export */ isNumber: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.isNumber),\n/* harmony export */ isString: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.isString),\n/* harmony export */ isUndefined: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.isUndefined),\n/* harmony export */ not: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.not),\n/* harmony export */ notNull: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.notNull),\n/* harmony export */ or: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.or),\n/* harmony export */ validator: () => (/* reexport safe */ _validators__WEBPACK_IMPORTED_MODULE_0__.validator)\n/* harmony export */ });\n/* harmony import */ var _validators__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./validators */ \"./src/validators/validators.ts\");\n/* harmony import */ var _body_validator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./body-validator */ \"./src/validators/body-validator.ts\");\n\n\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/validators/index.ts?");
77
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.bodyValidator = exports.custom = exports.validator = exports.or = exports.notNull = exports.not = exports.isUndefined = exports.isString = exports.isNumber = exports.isNull = exports.isDefined = exports.and = void 0;\nvar validators_1 = __webpack_require__(/*! ./validators */ \"./src/validators/validators.ts\");\nObject.defineProperty(exports, \"and\", ({ enumerable: true, get: function () { return validators_1.and; } }));\nObject.defineProperty(exports, \"isDefined\", ({ enumerable: true, get: function () { return validators_1.isDefined; } }));\nObject.defineProperty(exports, \"isNull\", ({ enumerable: true, get: function () { return validators_1.isNull; } }));\nObject.defineProperty(exports, \"isNumber\", ({ enumerable: true, get: function () { return validators_1.isNumber; } }));\nObject.defineProperty(exports, \"isString\", ({ enumerable: true, get: function () { return validators_1.isString; } }));\nObject.defineProperty(exports, \"isUndefined\", ({ enumerable: true, get: function () { return validators_1.isUndefined; } }));\nObject.defineProperty(exports, \"not\", ({ enumerable: true, get: function () { return validators_1.not; } }));\nObject.defineProperty(exports, \"notNull\", ({ enumerable: true, get: function () { return validators_1.notNull; } }));\nObject.defineProperty(exports, \"or\", ({ enumerable: true, get: function () { return validators_1.or; } }));\nObject.defineProperty(exports, \"validator\", ({ enumerable: true, get: function () { return validators_1.validator; } }));\nObject.defineProperty(exports, \"custom\", ({ enumerable: true, get: function () { return validators_1.custom; } }));\nvar body_validator_1 = __webpack_require__(/*! ./body-validator */ \"./src/validators/body-validator.ts\");\nObject.defineProperty(exports, \"bodyValidator\", ({ enumerable: true, get: function () { return body_validator_1.bodyValidator; } }));\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/validators/index.ts?");
78
78
 
79
79
  /***/ }),
80
80
 
@@ -82,9 +82,9 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
82
82
  /*!**************************************!*\
83
83
  !*** ./src/validators/validators.ts ***!
84
84
  \**************************************/
85
- /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
85
+ /***/ ((__unused_webpack_module, exports) => {
86
86
 
87
- eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AtomicValidator: () => (/* binding */ AtomicValidator),\n/* harmony export */ Validator: () => (/* binding */ Validator),\n/* harmony export */ and: () => (/* binding */ and),\n/* harmony export */ andAsync: () => (/* binding */ andAsync),\n/* harmony export */ custom: () => (/* binding */ custom),\n/* harmony export */ isDefined: () => (/* binding */ isDefined),\n/* harmony export */ isNull: () => (/* binding */ isNull),\n/* harmony export */ isNumber: () => (/* binding */ isNumber),\n/* harmony export */ isString: () => (/* binding */ isString),\n/* harmony export */ isUndefined: () => (/* binding */ isUndefined),\n/* harmony export */ not: () => (/* binding */ not),\n/* harmony export */ notNull: () => (/* binding */ notNull),\n/* harmony export */ or: () => (/* binding */ or),\n/* harmony export */ validator: () => (/* binding */ validator)\n/* harmony export */ });\nfunction validator(validationLogic, requestField) {\n return (req, res, next) => {\n // @ts-ignore\n applyValidation(req[requestField], validationLogic).then(errors => {\n const result = isThereAnyErrors(errors);\n if (result) {\n next(errors);\n }\n else {\n next();\n }\n }).catch(next);\n };\n}\nasync function applyValidation(obj, validationLogic) {\n const validationResult = {};\n for (const key in validationLogic) {\n const atomicValidator = validationLogic[key];\n if (atomicValidator) {\n if (atomicValidator instanceof Validator) {\n try {\n validationResult[key] = atomicValidator.validate(obj, key);\n if (validationResult[key] instanceof Promise) {\n validationResult[key] = await validationResult[key];\n console.log(`awaited result: ${validationResult[key]}`);\n }\n }\n catch (err) {\n validationResult[key] = false;\n }\n }\n else {\n if (obj[key] instanceof Array) {\n validationResult[key] = obj[key].map(objj => applyValidation(objj, atomicValidator));\n if (validationResult[key][0] instanceof Promise) {\n validationResult[key] = Promise.all(validationResult[key]);\n }\n }\n else {\n validationResult[key] = applyValidation(obj[key], atomicValidator);\n if (validationResult[key] instanceof Promise) {\n validationResult[key] = await validationResult[key];\n }\n }\n }\n }\n else {\n validationResult[key] = true;\n }\n }\n return validationResult;\n}\nfunction isThereAnyErrors(obj) {\n for (const [key, value] of Object.entries(obj)) {\n if (value === false) {\n return true;\n }\n else if (typeof value !== 'boolean') {\n const partialRes = isThereAnyErrors(value);\n if (partialRes) {\n return partialRes;\n }\n }\n }\n return false;\n}\n// type ValidationFunction<T> = (subject: T) => boolean;\nclass Validator {\n}\nclass CustomValidator extends Validator {\n constructor(validator) {\n super();\n this.validator = validator;\n }\n validate(subject, selectedField) {\n return this.validator(subject);\n }\n}\nfunction custom(validator) {\n return new CustomValidator(validator);\n}\nclass AtomicValidator extends Validator {\n constructor(implementation, queryField) {\n super();\n this.implementation = implementation;\n this.queryField = queryField;\n }\n validate(subject, selectedField) {\n return this.implementation(this.queryField ? subject[this.queryField] : subject[selectedField]);\n }\n}\nfunction isString(field) {\n return new AtomicValidator((subject) => {\n return typeof subject === 'string';\n }, field);\n}\nfunction isNumber(field) {\n return new AtomicValidator((subject) => {\n return typeof subject === 'number';\n }, field);\n}\nfunction isDefined(field) {\n return new AtomicValidator((subject) => {\n return subject != undefined;\n }, field);\n}\nfunction isUndefined(field) {\n return new AtomicValidator((subject) => {\n return subject === undefined;\n }, field);\n}\nfunction isNull(field) {\n return new AtomicValidator((subject) => {\n return subject === null;\n }, field);\n}\nfunction notNull(field) {\n return new AtomicValidator((subject) => {\n return subject !== null;\n }, field);\n}\nclass AndValidator extends Validator {\n constructor(...validationFunctions) {\n super();\n this.validationFunctions = validationFunctions;\n }\n validate(subject, selectedField) {\n return this.validationFunctions.every(eachValidator => eachValidator.validate(subject, selectedField));\n }\n}\nclass AndValidatorAsync extends Validator {\n constructor(...validationFunctions) {\n super();\n this.validationFunctions = validationFunctions;\n }\n async validate(subject, selectedField) {\n const allPromises = this.validationFunctions.map(eachValidator => eachValidator.validate(subject, selectedField));\n const allResults = await Promise.all(allPromises);\n return allResults.every(val => val);\n }\n}\nclass OrValidator extends Validator {\n constructor(...validationFunctions) {\n super();\n this.validationFunctions = validationFunctions;\n }\n validate(subject, selectedField) {\n return this.validationFunctions.some(eachValidator => eachValidator.validate(subject, selectedField));\n }\n}\nclass NotValidator extends Validator {\n constructor(validationFunctions) {\n super();\n this.validationFunction = validationFunctions;\n }\n validate(subject, selectedField) {\n return !this.validationFunction.validate(subject, selectedField);\n }\n}\nfunction and(...validationFunctions) {\n return new AndValidator(...validationFunctions);\n}\nfunction andAsync(...validationFunctions) {\n return new AndValidatorAsync(...validationFunctions);\n}\nfunction or(...validationFunctions) {\n return new OrValidator(...validationFunctions);\n}\nfunction not(validationFunction) {\n return new NotValidator(validationFunction);\n}\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/validators/validators.ts?");
87
+ eval("\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\nexports.not = exports.or = exports.andAsync = exports.and = exports.notNull = exports.isNull = exports.isUndefined = exports.isDefined = exports.isNumber = exports.isString = exports.AtomicValidator = exports.custom = exports.Validator = exports.validator = void 0;\nfunction validator(validationLogic, requestField) {\n return (req, res, next) => {\n // @ts-ignore\n applyValidation(req[requestField], validationLogic).then(errors => {\n const result = isThereAnyErrors(errors);\n if (result) {\n next(errors);\n }\n else {\n next();\n }\n }).catch(next);\n };\n}\nexports.validator = validator;\nasync function applyValidation(obj, validationLogic) {\n const validationResult = {};\n for (const key in validationLogic) {\n const atomicValidator = validationLogic[key];\n if (atomicValidator) {\n if (atomicValidator instanceof Validator) {\n try {\n validationResult[key] = atomicValidator.validate(obj, key);\n if (validationResult[key] instanceof Promise) {\n validationResult[key] = await validationResult[key];\n console.log(`awaited result: ${validationResult[key]}`);\n }\n }\n catch (err) {\n validationResult[key] = false;\n }\n }\n else {\n if (obj[key] instanceof Array) {\n validationResult[key] = obj[key].map(objj => applyValidation(objj, atomicValidator));\n if (validationResult[key][0] instanceof Promise) {\n validationResult[key] = Promise.all(validationResult[key]);\n }\n }\n else {\n validationResult[key] = applyValidation(obj[key], atomicValidator);\n if (validationResult[key] instanceof Promise) {\n validationResult[key] = await validationResult[key];\n }\n }\n }\n }\n else {\n validationResult[key] = true;\n }\n }\n return validationResult;\n}\nfunction isThereAnyErrors(obj) {\n for (const [key, value] of Object.entries(obj)) {\n if (value === false) {\n return true;\n }\n else if (typeof value !== 'boolean') {\n const partialRes = isThereAnyErrors(value);\n if (partialRes) {\n return partialRes;\n }\n }\n }\n return false;\n}\n// type ValidationFunction<T> = (subject: T) => boolean;\nclass Validator {\n}\nexports.Validator = Validator;\nclass CustomValidator extends Validator {\n constructor(validator) {\n super();\n this.validator = validator;\n }\n validate(subject, selectedField) {\n return this.validator(subject);\n }\n}\nfunction custom(validator) {\n return new CustomValidator(validator);\n}\nexports.custom = custom;\nclass AtomicValidator extends Validator {\n constructor(implementation, queryField) {\n super();\n this.implementation = implementation;\n this.queryField = queryField;\n }\n validate(subject, selectedField) {\n return this.implementation(this.queryField ? subject[this.queryField] : subject[selectedField]);\n }\n}\nexports.AtomicValidator = AtomicValidator;\nfunction isString(field) {\n return new AtomicValidator((subject) => {\n return typeof subject === 'string';\n }, field);\n}\nexports.isString = isString;\nfunction isNumber(field) {\n return new AtomicValidator((subject) => {\n return typeof subject === 'number';\n }, field);\n}\nexports.isNumber = isNumber;\nfunction isDefined(field) {\n return new AtomicValidator((subject) => {\n return subject != undefined;\n }, field);\n}\nexports.isDefined = isDefined;\nfunction isUndefined(field) {\n return new AtomicValidator((subject) => {\n return subject === undefined;\n }, field);\n}\nexports.isUndefined = isUndefined;\nfunction isNull(field) {\n return new AtomicValidator((subject) => {\n return subject === null;\n }, field);\n}\nexports.isNull = isNull;\nfunction notNull(field) {\n return new AtomicValidator((subject) => {\n return subject !== null;\n }, field);\n}\nexports.notNull = notNull;\nclass AndValidator extends Validator {\n constructor(...validationFunctions) {\n super();\n this.validationFunctions = validationFunctions;\n }\n validate(subject, selectedField) {\n return this.validationFunctions.every(eachValidator => eachValidator.validate(subject, selectedField));\n }\n}\nclass AndValidatorAsync extends Validator {\n constructor(...validationFunctions) {\n super();\n this.validationFunctions = validationFunctions;\n }\n async validate(subject, selectedField) {\n const allPromises = this.validationFunctions.map(eachValidator => eachValidator.validate(subject, selectedField));\n const allResults = await Promise.all(allPromises);\n return allResults.every(val => val);\n }\n}\nclass OrValidator extends Validator {\n constructor(...validationFunctions) {\n super();\n this.validationFunctions = validationFunctions;\n }\n validate(subject, selectedField) {\n return this.validationFunctions.some(eachValidator => eachValidator.validate(subject, selectedField));\n }\n}\nclass NotValidator extends Validator {\n constructor(validationFunctions) {\n super();\n this.validationFunction = validationFunctions;\n }\n validate(subject, selectedField) {\n return !this.validationFunction.validate(subject, selectedField);\n }\n}\nfunction and(...validationFunctions) {\n return new AndValidator(...validationFunctions);\n}\nexports.and = and;\nfunction andAsync(...validationFunctions) {\n return new AndValidatorAsync(...validationFunctions);\n}\nexports.andAsync = andAsync;\nfunction or(...validationFunctions) {\n return new OrValidator(...validationFunctions);\n}\nexports.or = or;\nfunction not(validationFunction) {\n return new NotValidator(validationFunction);\n}\nexports.not = not;\n\n\n//# sourceURL=webpack://@galeh/chuka/./src/validators/validators.ts?");
88
88
 
89
89
  /***/ }),
90
90
 
@@ -165,51 +165,10 @@ module.exports = require("tslib");
165
165
  /******/ }
166
166
  /******/
167
167
  /************************************************************************/
168
- /******/ /* webpack/runtime/compat get default export */
169
- /******/ (() => {
170
- /******/ // getDefaultExport function for compatibility with non-harmony modules
171
- /******/ __webpack_require__.n = (module) => {
172
- /******/ var getter = module && module.__esModule ?
173
- /******/ () => (module['default']) :
174
- /******/ () => (module);
175
- /******/ __webpack_require__.d(getter, { a: getter });
176
- /******/ return getter;
177
- /******/ };
178
- /******/ })();
179
- /******/
180
- /******/ /* webpack/runtime/define property getters */
181
- /******/ (() => {
182
- /******/ // define getter functions for harmony exports
183
- /******/ __webpack_require__.d = (exports, definition) => {
184
- /******/ for(var key in definition) {
185
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
186
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
187
- /******/ }
188
- /******/ }
189
- /******/ };
190
- /******/ })();
191
- /******/
192
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
193
- /******/ (() => {
194
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
195
- /******/ })();
196
- /******/
197
- /******/ /* webpack/runtime/make namespace object */
198
- /******/ (() => {
199
- /******/ // define __esModule on exports
200
- /******/ __webpack_require__.r = (exports) => {
201
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
202
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
203
- /******/ }
204
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
205
- /******/ };
206
- /******/ })();
207
- /******/
208
- /************************************************************************/
209
168
  /******/
210
169
  /******/ // startup
211
170
  /******/ // Load entry module and return exports
212
- /******/ // This entry module can't be inlined because the eval devtool is used.
171
+ /******/ // This entry module is referenced by other modules so it can't be inlined
213
172
  /******/ var __webpack_exports__ = __webpack_require__("./src/index.ts");
214
173
  /******/ var __webpack_export_target__ = exports;
215
174
  /******/ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galeh/chuka",
3
- "version": "1.1.4",
3
+ "version": "1.1.5",
4
4
  "description": "simple yet robust wrapper for expressjs",
5
5
  "keywords": [
6
6
  "chuka",
@@ -37,5 +37,6 @@
37
37
  "url": "https://github.com/hgaleh/chuka.git"
38
38
  },
39
39
  "type": "commonjs",
40
- "main": "index.js"
40
+ "main": "index.js",
41
+ "types": "index.d.ts"
41
42
  }