@galeh/chuka 1.1.0 → 1.1.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/.github/workflows/webpack.yml +34 -0
- package/README.md +2 -2
- package/config/api-extractor.decorators.json +427 -0
- package/config/api-extractor.index.json +427 -0
- package/config/api-extractor.middlewares.json +427 -0
- package/config/api-extractor.validators.json +427 -0
- package/package.json +49 -40
- package/sample/01-cats-app/package-lock.json +283 -0
- package/sample/01-cats-app/package.json +19 -0
- package/sample/01-cats-app/src/cats/cat-model.ts +9 -0
- package/sample/01-cats-app/src/cats/cats-controller.ts +44 -0
- package/sample/01-cats-app/src/cats/cats-service-interface.ts +7 -0
- package/sample/01-cats-app/src/cats/cats-service.ts +27 -0
- package/sample/01-cats-app/src/cats/create-logger.ts +8 -0
- package/sample/01-cats-app/src/main.ts +30 -0
- package/sample/01-cats-app/tsconfig.json +112 -0
- package/sample/02-socket/package-lock.json +442 -0
- package/sample/02-socket/package.json +20 -0
- package/sample/02-socket/src/controllers/http-controller.ts +14 -0
- package/sample/02-socket/src/controllers/socket-controller.ts +18 -0
- package/sample/02-socket/src/main.ts +46 -0
- package/sample/02-socket/src/middleware/create-session.ts +9 -0
- package/sample/02-socket/tsconfig.json +112 -0
- package/sample/03-authentication/db/create.sql +6 -0
- package/sample/03-authentication/package-lock.json +1832 -0
- package/sample/03-authentication/package.json +23 -0
- package/sample/03-authentication/src/config.ts +21 -0
- package/sample/03-authentication/src/controllers/auth-controller.ts +54 -0
- package/sample/03-authentication/src/enums/injection-tokens.ts +5 -0
- package/sample/03-authentication/src/enums/result-codes.ts +4 -0
- package/sample/03-authentication/src/exceptions/error.ts +7 -0
- package/sample/03-authentication/src/exceptions/password-not-found-exception.ts +9 -0
- package/sample/03-authentication/src/exceptions/unauthorized-exception.ts +9 -0
- package/sample/03-authentication/src/exceptions/user-already-exist.ts +9 -0
- package/sample/03-authentication/src/exceptions/user-not-found.ts +9 -0
- package/sample/03-authentication/src/exceptions/wrong-login-info-exception.ts +8 -0
- package/sample/03-authentication/src/main.ts +42 -0
- package/sample/03-authentication/src/middlewares/auth-handler.ts +17 -0
- package/sample/03-authentication/src/middlewares/global-error-handler.ts +21 -0
- package/sample/03-authentication/src/models/user-model.ts +6 -0
- package/sample/03-authentication/src/services/auth-service.ts +50 -0
- package/sample/03-authentication/src/services/interfaces/auth-service-interface.ts +7 -0
- package/sample/03-authentication/src/services/interfaces/user-service-interface.ts +7 -0
- package/sample/03-authentication/src/services/user-service.ts +75 -0
- package/sample/03-authentication/src/types/connection.ts +3 -0
- package/sample/03-authentication/src/types/token.ts +3 -0
- package/sample/03-authentication/src/utils/crypto.ts +26 -0
- package/sample/03-authentication/tsconfig.json +112 -0
- package/scripts/build.bash +17 -0
- package/scripts/create-package-json.js +15 -0
- package/src/app.ts +197 -0
- package/src/controller.ts +204 -0
- package/src/decorators/index.ts +1 -0
- package/src/index.ts +3 -0
- package/src/middlewares/index.ts +1 -0
- package/src/validators/body-validator.ts +9 -0
- package/src/validators/index.ts +2 -0
- package/src/validators/query-validator.ts +9 -0
- package/src/validators/validators.ts +216 -0
- package/tsconfig.json +112 -0
- package/webpack.config.js +46 -0
- package/decorators.d.ts +0 -8
- package/decorators.js +0 -107
- package/index.d.ts +0 -202
- package/index.js +0 -167
- package/middlewares.d.ts +0 -20
- package/middlewares.js +0 -107
- package/validators.d.ts +0 -60
- package/validators.js +0 -105
package/tsconfig.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Projects */
|
|
6
|
+
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
+
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
+
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
+
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
+
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
+
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
+
|
|
13
|
+
/* Language and Environment */
|
|
14
|
+
"target": "es2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
+
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
+
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
+
"experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
+
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
+
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
+
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
+
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
+
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
+
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
+
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
+
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
+
|
|
27
|
+
/* Modules */
|
|
28
|
+
"module": "es2020", /* Specify what module code is generated. */
|
|
29
|
+
"rootDir": "./src", /* Specify the root folder within your source files. */
|
|
30
|
+
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
+
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
+
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
+
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
+
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
+
// "types": [ "express", "express-ws", "ws" ], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
+
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
+
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
+
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
+
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
+
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
+
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
+
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
+
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
+
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
+
|
|
46
|
+
/* JavaScript Support */
|
|
47
|
+
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
+
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
+
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
+
|
|
51
|
+
/* Emit */
|
|
52
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
+
"declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
+
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
+
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
+
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
+
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
+
"outDir": "./dist-ts", /* Specify an output folder for all emitted files. */
|
|
59
|
+
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
+
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
+
"importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
+
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
+
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
+
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
+
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
+
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
+
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
+
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
+
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
+
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
+
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
+
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
+
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
+
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
+
|
|
76
|
+
/* Interop Constraints */
|
|
77
|
+
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
+
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
+
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
+
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
+
|
|
84
|
+
/* Type Checking */
|
|
85
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
+
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
+
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
+
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
+
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
+
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
+
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
+
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
+
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
+
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
+
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
+
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
+
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
+
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
+
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
+
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
+
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
+
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
+
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
+
|
|
105
|
+
/* Completeness */
|
|
106
|
+
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
+
},
|
|
109
|
+
"include": [
|
|
110
|
+
"src/"
|
|
111
|
+
]
|
|
112
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
const { resolve } = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = [
|
|
4
|
+
createConfig(resolve(__dirname, './src/index.ts'), 'index.js', '@galeh/chuka'),
|
|
5
|
+
createConfig(resolve(__dirname, './src/decorators/index.ts'), 'decorators.js', '@galeh/chuka/decorators'),
|
|
6
|
+
createConfig(resolve(__dirname, './src/middlewares/index.ts'), 'middlewares.js', '@galeh/chuka/middlewares'),
|
|
7
|
+
createConfig(resolve(__dirname, './src/validators/index.ts'), 'validators.js', '@galeh/chuka/validators'),
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
function createConfig(entryFile, outputFile, libname) {
|
|
11
|
+
return {
|
|
12
|
+
mode: 'development',
|
|
13
|
+
entry: entryFile,
|
|
14
|
+
target: 'node12.7',
|
|
15
|
+
output: {
|
|
16
|
+
path: resolve(__dirname, 'dist/chuka'),
|
|
17
|
+
filename: outputFile,
|
|
18
|
+
libraryTarget: 'commonjs'
|
|
19
|
+
},
|
|
20
|
+
module: {
|
|
21
|
+
rules: [
|
|
22
|
+
{
|
|
23
|
+
test: /\.ts$/,
|
|
24
|
+
use: 'ts-loader',
|
|
25
|
+
exclude: /node_modules/
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
resolve: {
|
|
30
|
+
extensions: ['.ts']
|
|
31
|
+
},
|
|
32
|
+
externals: {
|
|
33
|
+
"express": "express",
|
|
34
|
+
"express-ws": "express-ws",
|
|
35
|
+
"inversify": "inversify",
|
|
36
|
+
"reflect-metadata": "reflect-metadata",
|
|
37
|
+
"tslib": "tslib",
|
|
38
|
+
"@types/express": "@types/express",
|
|
39
|
+
"@types/express-ws": "@types/express-ws",
|
|
40
|
+
"@types/ws": "@types/ws"
|
|
41
|
+
},
|
|
42
|
+
experiments: {
|
|
43
|
+
outputModule: true
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
package/decorators.d.ts
DELETED
package/decorators.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
3
|
-
* This devtool is neither made for production nor for readable output files.
|
|
4
|
-
* It uses "eval()" calls to create a separate source file in the browser devtools.
|
|
5
|
-
* If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
|
|
6
|
-
* or disable the default devtool with "devtool: false".
|
|
7
|
-
* If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
|
|
8
|
-
*/
|
|
9
|
-
/******/ var __webpack_modules__ = ({
|
|
10
|
-
|
|
11
|
-
/***/ "./src/decorators/index.ts":
|
|
12
|
-
/*!*********************************!*\
|
|
13
|
-
!*** ./src/decorators/index.ts ***!
|
|
14
|
-
\*********************************/
|
|
15
|
-
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
16
|
-
|
|
17
|
-
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?");
|
|
18
|
-
|
|
19
|
-
/***/ }),
|
|
20
|
-
|
|
21
|
-
/***/ "inversify":
|
|
22
|
-
/*!****************************!*\
|
|
23
|
-
!*** external "inversify" ***!
|
|
24
|
-
\****************************/
|
|
25
|
-
/***/ ((module) => {
|
|
26
|
-
|
|
27
|
-
module.exports = require("inversify");
|
|
28
|
-
|
|
29
|
-
/***/ })
|
|
30
|
-
|
|
31
|
-
/******/ });
|
|
32
|
-
/************************************************************************/
|
|
33
|
-
/******/ // The module cache
|
|
34
|
-
/******/ var __webpack_module_cache__ = {};
|
|
35
|
-
/******/
|
|
36
|
-
/******/ // The require function
|
|
37
|
-
/******/ function __webpack_require__(moduleId) {
|
|
38
|
-
/******/ // Check if module is in cache
|
|
39
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
40
|
-
/******/ if (cachedModule !== undefined) {
|
|
41
|
-
/******/ return cachedModule.exports;
|
|
42
|
-
/******/ }
|
|
43
|
-
/******/ // Create a new module (and put it into the cache)
|
|
44
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
45
|
-
/******/ // no module.id needed
|
|
46
|
-
/******/ // no module.loaded needed
|
|
47
|
-
/******/ exports: {}
|
|
48
|
-
/******/ };
|
|
49
|
-
/******/
|
|
50
|
-
/******/ // Execute the module function
|
|
51
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
52
|
-
/******/
|
|
53
|
-
/******/ // Return the exports of the module
|
|
54
|
-
/******/ return module.exports;
|
|
55
|
-
/******/ }
|
|
56
|
-
/******/
|
|
57
|
-
/************************************************************************/
|
|
58
|
-
/******/ /* webpack/runtime/compat get default export */
|
|
59
|
-
/******/ (() => {
|
|
60
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
61
|
-
/******/ __webpack_require__.n = (module) => {
|
|
62
|
-
/******/ var getter = module && module.__esModule ?
|
|
63
|
-
/******/ () => (module['default']) :
|
|
64
|
-
/******/ () => (module);
|
|
65
|
-
/******/ __webpack_require__.d(getter, { a: getter });
|
|
66
|
-
/******/ return getter;
|
|
67
|
-
/******/ };
|
|
68
|
-
/******/ })();
|
|
69
|
-
/******/
|
|
70
|
-
/******/ /* webpack/runtime/define property getters */
|
|
71
|
-
/******/ (() => {
|
|
72
|
-
/******/ // define getter functions for harmony exports
|
|
73
|
-
/******/ __webpack_require__.d = (exports, definition) => {
|
|
74
|
-
/******/ for(var key in definition) {
|
|
75
|
-
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
76
|
-
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
77
|
-
/******/ }
|
|
78
|
-
/******/ }
|
|
79
|
-
/******/ };
|
|
80
|
-
/******/ })();
|
|
81
|
-
/******/
|
|
82
|
-
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
83
|
-
/******/ (() => {
|
|
84
|
-
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
85
|
-
/******/ })();
|
|
86
|
-
/******/
|
|
87
|
-
/******/ /* webpack/runtime/make namespace object */
|
|
88
|
-
/******/ (() => {
|
|
89
|
-
/******/ // define __esModule on exports
|
|
90
|
-
/******/ __webpack_require__.r = (exports) => {
|
|
91
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
92
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
93
|
-
/******/ }
|
|
94
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
95
|
-
/******/ };
|
|
96
|
-
/******/ })();
|
|
97
|
-
/******/
|
|
98
|
-
/************************************************************************/
|
|
99
|
-
/******/
|
|
100
|
-
/******/ // startup
|
|
101
|
-
/******/ // Load entry module and return exports
|
|
102
|
-
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
103
|
-
/******/ var __webpack_exports__ = __webpack_require__("./src/decorators/index.ts");
|
|
104
|
-
/******/ var __webpack_export_target__ = exports;
|
|
105
|
-
/******/ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
|
|
106
|
-
/******/ if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
|
|
107
|
-
/******/
|
package/index.d.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import * as express from 'express';
|
|
2
|
-
import { interfaces } from 'inversify';
|
|
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';
|
|
7
|
-
|
|
8
|
-
declare interface ApplicationConfig {
|
|
9
|
-
routes: Array<Route>;
|
|
10
|
-
dependencies?: Array<Dependency>;
|
|
11
|
-
middlewares?: Array<RequestHandlerParams<any>>;
|
|
12
|
-
on?: EventCallback[];
|
|
13
|
-
set?: Partial<Settings>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export declare class Controller {
|
|
17
|
-
private router;
|
|
18
|
-
constructor();
|
|
19
|
-
private [setControllerSymbol];
|
|
20
|
-
private [getRouterSymbol];
|
|
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
|
-
}
|
|
32
|
-
|
|
33
|
-
export declare function createApp(config: ApplicationConfig): express.Application;
|
|
34
|
-
|
|
35
|
-
declare interface Dependency {
|
|
36
|
-
provide: string;
|
|
37
|
-
useClass?: Type<any>;
|
|
38
|
-
useValue?: any;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare interface ErrorHandler<T> {
|
|
42
|
-
(err: any, req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
declare type EventCallback = {
|
|
46
|
-
event: 'connect' | 'connection' | 'close' | 'error' | 'listening' | 'lookup' | 'ready' | 'timeout' | 'mount';
|
|
47
|
-
callback: (parent: express.Application) => void;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
declare type GetRouteParameter<S extends string> = RemoveTail<RemoveTail<RemoveTail<S, `/${string}`>, `-${string}`>, `.${string}`>;
|
|
51
|
-
|
|
52
|
-
declare const getRouterSymbol: unique symbol;
|
|
53
|
-
|
|
54
|
-
export { interfaces }
|
|
55
|
-
|
|
56
|
-
declare type Merge<A, B> = {
|
|
57
|
-
[k in keyof A & keyof B]: (A & B)[k] extends never ? B[k] : 0 extends 1 & (A & B)[k] ? B[k] : (A & B)[k];
|
|
58
|
-
} & Omit<A, keyof B> & Omit<B, keyof A>;
|
|
59
|
-
|
|
60
|
-
declare type MergePartial<A, B> = {
|
|
61
|
-
[k in keyof A & keyof B]: (A & B)[k] extends never ? B[k] : 0 extends 1 & (A & B)[k] ? B[k] : (A & B)[k];
|
|
62
|
-
} & Omit<A, keyof B> & Partial<Omit<B, keyof A>>;
|
|
63
|
-
|
|
64
|
-
export declare interface Middleware<T> {
|
|
65
|
-
(req: MergePartial<Request_2, T>, res: Response_2, next: NextFunction): void;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
declare class MiniController<T> implements MiniControllerInterface<T> {
|
|
69
|
-
private router;
|
|
70
|
-
private middlewares;
|
|
71
|
-
constructor(router: any, middlewares: any[]);
|
|
72
|
-
all: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
73
|
-
get: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
74
|
-
post: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
75
|
-
put: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
76
|
-
delete: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
77
|
-
patch: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
78
|
-
options: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
79
|
-
head: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
80
|
-
checkout: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
81
|
-
connect: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
82
|
-
copy: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
83
|
-
lock: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
84
|
-
merge: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
85
|
-
mkactivity: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
86
|
-
mkcol: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
87
|
-
move: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
88
|
-
'm-search': <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
89
|
-
notify: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
90
|
-
propfind: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
91
|
-
proppatch: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
92
|
-
purge: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
93
|
-
report: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
94
|
-
search: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
95
|
-
subscribe: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
96
|
-
trace: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
97
|
-
unlock: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
98
|
-
unsubscribe: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
99
|
-
link: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
100
|
-
unlink: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
101
|
-
private methodImplementation;
|
|
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
|
-
}
|
|
107
|
-
|
|
108
|
-
declare interface MiniControllerInterface<T> {
|
|
109
|
-
all: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
110
|
-
get: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
111
|
-
post: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
112
|
-
put: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
113
|
-
delete: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
114
|
-
patch: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
115
|
-
options: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
116
|
-
head: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
117
|
-
checkout: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
118
|
-
connect: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
119
|
-
copy: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
120
|
-
lock: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
121
|
-
merge: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
122
|
-
mkactivity: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
123
|
-
mkcol: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
124
|
-
move: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
125
|
-
"m-search": <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
126
|
-
notify: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
127
|
-
propfind: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
128
|
-
proppatch: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
129
|
-
purge: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
130
|
-
report: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
131
|
-
search: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
132
|
-
subscribe: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
133
|
-
trace: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
134
|
-
unlock: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
135
|
-
unsubscribe: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
136
|
-
link: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
137
|
-
unlink: <Path extends string>(path: Path, handler: RequestHandler<T, RouteParameters<Path>>) => void;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
declare interface MiniControllerWS<T> {
|
|
141
|
-
(handler: WSHandler<T>): void;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
declare interface ParamsDictionary {
|
|
145
|
-
[key: string]: string;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
declare type PathParams = string | RegExp | Array<string | RegExp>;
|
|
149
|
-
|
|
150
|
-
declare type RemoveTail<S extends string, Tail extends string> = S extends `${infer P}${Tail}` ? P : S;
|
|
151
|
-
|
|
152
|
-
declare interface RequestHandler<T, P = ParamsDictionary> {
|
|
153
|
-
(req: Merge<Request_2, T & {
|
|
154
|
-
params: P;
|
|
155
|
-
}>, res: Response_2, next: NextFunction): void;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
declare type RequestHandlerParams<T> = Middleware<T> | ErrorHandler<T>;
|
|
159
|
-
|
|
160
|
-
declare interface Route {
|
|
161
|
-
path: PathParams;
|
|
162
|
-
controller: Type<Controller>;
|
|
163
|
-
children?: Array<Route>;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
declare type RouteParameters<Route extends string> = string extends Route ? ParamsDictionary : Route extends `${string}(${string}` ? ParamsDictionary : Route extends `${string}:${infer Rest}` ? (GetRouteParameter<Rest> extends never ? ParamsDictionary : GetRouteParameter<Rest> extends `${infer ParamName}?` ? {
|
|
167
|
-
[P in ParamName]?: string;
|
|
168
|
-
} : {
|
|
169
|
-
[P in GetRouteParameter<Rest>]: string;
|
|
170
|
-
}) & (Rest extends `${GetRouteParameter<Rest>}${infer Next}` ? RouteParameters<Next> : unknown) : {};
|
|
171
|
-
|
|
172
|
-
declare const setControllerSymbol: unique symbol;
|
|
173
|
-
|
|
174
|
-
declare interface Settings extends Record<SettingsEnumKeys, any> {
|
|
175
|
-
caseSensitiveRouting: boolean;
|
|
176
|
-
env: string;
|
|
177
|
-
etag: any;
|
|
178
|
-
jsonpCallbackName: string;
|
|
179
|
-
jsonEscape: boolean;
|
|
180
|
-
jsonReplacer: any;
|
|
181
|
-
jsonSpaces: any;
|
|
182
|
-
queryParser: any;
|
|
183
|
-
strictRouting: boolean;
|
|
184
|
-
subdomainOffset: number;
|
|
185
|
-
trustProxy: any;
|
|
186
|
-
views: string | string[];
|
|
187
|
-
viewCache: boolean;
|
|
188
|
-
viewEngine: string;
|
|
189
|
-
xPoweredBy: boolean;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
declare type SettingsEnumKeys = 'caseSensitiveRouting' | 'env' | 'etag' | 'jsonpCallbackName' | 'jsonEscape' | 'jsonReplacer' | 'jsonSpaces' | 'queryParser' | 'strictRouting' | 'subdomainOffset' | 'trustProxy' | 'views' | 'viewCache' | 'viewEngine' | 'xPoweredBy';
|
|
193
|
-
|
|
194
|
-
declare interface Type<T> extends Function {
|
|
195
|
-
new (...args: any[]): T;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
declare type WSHandler<T> = (ws: WebSocket_2, req: Merge<Request_2, T>) => void;
|
|
199
|
-
|
|
200
|
-
export declare type WSMiddleware<T> = (ws: WebSocket_2, req: MergePartial<Request_2, T>, next: NextFunction) => void;
|
|
201
|
-
|
|
202
|
-
export { }
|