@nestia/core 1.1.1 → 1.1.2-dev.20230503-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.
Files changed (89) hide show
  1. package/lib/decorators/DynamicModule.d.ts +26 -23
  2. package/lib/decorators/DynamicModule.js +103 -103
  3. package/lib/decorators/DynamicModule.js.map +1 -1
  4. package/lib/decorators/EncryptedBody.d.ts +23 -23
  5. package/lib/decorators/EncryptedBody.js +125 -125
  6. package/lib/decorators/EncryptedController.d.ts +31 -31
  7. package/lib/decorators/EncryptedController.js +41 -41
  8. package/lib/decorators/EncryptedModule.d.ts +52 -49
  9. package/lib/decorators/EncryptedModule.js +161 -161
  10. package/lib/decorators/EncryptedModule.js.map +1 -1
  11. package/lib/decorators/EncryptedRoute.d.ts +78 -78
  12. package/lib/decorators/EncryptedRoute.js +216 -216
  13. package/lib/decorators/PlainBody.d.ts +22 -22
  14. package/lib/decorators/PlainBody.js +82 -82
  15. package/lib/decorators/TypedBody.d.ts +16 -16
  16. package/lib/decorators/TypedBody.js +94 -94
  17. package/lib/decorators/TypedParam.d.ts +31 -31
  18. package/lib/decorators/TypedParam.js +68 -65
  19. package/lib/decorators/TypedParam.js.map +1 -1
  20. package/lib/decorators/TypedQuery.d.ts +14 -14
  21. package/lib/decorators/TypedQuery.js +124 -124
  22. package/lib/decorators/TypedRoute.d.ts +72 -72
  23. package/lib/decorators/TypedRoute.js +185 -185
  24. package/lib/decorators/internal/EncryptedConstant.d.ts +1 -1
  25. package/lib/decorators/internal/EncryptedConstant.js +7 -7
  26. package/lib/decorators/internal/TransformError.d.ts +1 -1
  27. package/lib/decorators/internal/TransformError.js +10 -10
  28. package/lib/decorators/internal/TransformError.js.map +1 -1
  29. package/lib/decorators/internal/get_path_and_stringify.d.ts +1 -1
  30. package/lib/decorators/internal/get_path_and_stringify.js +78 -78
  31. package/lib/decorators/internal/headers_to_object.d.ts +3 -3
  32. package/lib/decorators/internal/headers_to_object.js +49 -49
  33. package/lib/decorators/internal/load_controller.d.ts +5 -2
  34. package/lib/decorators/internal/load_controller.js +152 -151
  35. package/lib/decorators/internal/load_controller.js.map +1 -1
  36. package/lib/decorators/internal/route_error.d.ts +2 -2
  37. package/lib/decorators/internal/route_error.js +86 -86
  38. package/lib/decorators/internal/validate_request_body.d.ts +2 -2
  39. package/lib/decorators/internal/validate_request_body.js +57 -57
  40. package/lib/index.d.ts +3 -3
  41. package/lib/index.js +31 -31
  42. package/lib/module.d.ts +12 -12
  43. package/lib/module.js +28 -28
  44. package/lib/options/INestiaTransformOptions.d.ts +4 -4
  45. package/lib/options/INestiaTransformOptions.js +2 -2
  46. package/lib/options/INestiaTransformProject.d.ts +5 -5
  47. package/lib/options/INestiaTransformProject.js +2 -2
  48. package/lib/options/IRequestBodyValidator.d.ts +16 -16
  49. package/lib/options/IRequestBodyValidator.js +2 -2
  50. package/lib/options/IResponseBodyStringifier.d.ts +20 -20
  51. package/lib/options/IResponseBodyStringifier.js +2 -2
  52. package/lib/programmers/TypedBodyProgrammer.d.ts +5 -5
  53. package/lib/programmers/TypedBodyProgrammer.js +47 -47
  54. package/lib/programmers/TypedParamProgrammer.d.ts +5 -5
  55. package/lib/programmers/TypedParamProgrammer.js +107 -107
  56. package/lib/programmers/TypedQueryProgrammer.d.ts +5 -5
  57. package/lib/programmers/TypedQueryProgrammer.js +263 -263
  58. package/lib/programmers/TypedRouteProgrammer.d.ts +5 -5
  59. package/lib/programmers/TypedRouteProgrammer.js +49 -49
  60. package/lib/transform.d.ts +3 -3
  61. package/lib/transform.js +20 -20
  62. package/lib/transformers/FileTransformer.d.ts +5 -5
  63. package/lib/transformers/FileTransformer.js +32 -32
  64. package/lib/transformers/MethodDecoratorTransformer.d.ts +5 -5
  65. package/lib/transformers/MethodDecoratorTransformer.js +87 -87
  66. package/lib/transformers/MethodTransformer.d.ts +5 -5
  67. package/lib/transformers/MethodTransformer.js +54 -54
  68. package/lib/transformers/NodeTransformer.d.ts +5 -5
  69. package/lib/transformers/NodeTransformer.js +20 -20
  70. package/lib/transformers/ParameterDecoratorTransformer.d.ts +5 -5
  71. package/lib/transformers/ParameterDecoratorTransformer.js +65 -65
  72. package/lib/transformers/ParameterTransformer.d.ts +5 -5
  73. package/lib/transformers/ParameterTransformer.js +33 -33
  74. package/lib/typings/Creator.d.ts +3 -3
  75. package/lib/typings/Creator.js +2 -2
  76. package/lib/utils/ExceptionManager.d.ts +64 -64
  77. package/lib/utils/ExceptionManager.js +112 -112
  78. package/lib/utils/Singleton.d.ts +1 -1
  79. package/lib/utils/Singleton.js +23 -23
  80. package/lib/utils/SourceFinder.d.ts +9 -0
  81. package/lib/utils/SourceFinder.js +239 -0
  82. package/lib/utils/SourceFinder.js.map +1 -0
  83. package/package.json +7 -7
  84. package/src/decorators/DynamicModule.ts +1 -1
  85. package/src/decorators/EncryptedModule.ts +1 -1
  86. package/src/decorators/TypedParam.ts +6 -5
  87. package/src/decorators/internal/TransformError.ts +1 -1
  88. package/src/decorators/internal/load_controller.ts +32 -25
  89. package/src/utils/SourceFinder.ts +60 -0
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __read = (this && this.__read) || function (o, n) {
39
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
40
+ if (!m) return o;
41
+ var i = m.call(o), r, ar = [], e;
42
+ try {
43
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
+ }
45
+ catch (error) { e = { error: error }; }
46
+ finally {
47
+ try {
48
+ if (r && !r.done && (m = i["return"])) m.call(i);
49
+ }
50
+ finally { if (e) throw e.error; }
51
+ }
52
+ return ar;
53
+ };
54
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
+ if (ar || !(i in from)) {
57
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
+ ar[i] = from[i];
59
+ }
60
+ }
61
+ return to.concat(ar || Array.prototype.slice.call(from));
62
+ };
63
+ var __values = (this && this.__values) || function(o) {
64
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
65
+ if (m) return m.call(o);
66
+ if (o && typeof o.length === "number") return {
67
+ next: function () {
68
+ if (o && i >= o.length) o = void 0;
69
+ return { value: o && o[i++], done: !o };
70
+ }
71
+ };
72
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
73
+ };
74
+ var __importDefault = (this && this.__importDefault) || function (mod) {
75
+ return (mod && mod.__esModule) ? mod : { "default": mod };
76
+ };
77
+ Object.defineProperty(exports, "__esModule", { value: true });
78
+ exports.SourceFinder = void 0;
79
+ var fs_1 = __importDefault(require("fs"));
80
+ var glob_1 = __importDefault(require("glob"));
81
+ var path_1 = __importDefault(require("path"));
82
+ var SourceFinder;
83
+ (function (SourceFinder) {
84
+ var _this = this;
85
+ SourceFinder.find = function (props) { return __awaiter(_this, void 0, void 0, function () {
86
+ var dict;
87
+ var _a;
88
+ return __generator(this, function (_b) {
89
+ switch (_b.label) {
90
+ case 0:
91
+ dict = new Set();
92
+ return [4 /*yield*/, emplace(props.filter)(props.include)(function (str) { return dict.add(str); })];
93
+ case 1:
94
+ _b.sent();
95
+ if (!((_a = props.exclude) === null || _a === void 0 ? void 0 : _a.length)) return [3 /*break*/, 3];
96
+ return [4 /*yield*/, emplace(props.filter)(props.exclude)(function (str) {
97
+ return dict.delete(str);
98
+ })];
99
+ case 2:
100
+ _b.sent();
101
+ _b.label = 3;
102
+ case 3: return [2 /*return*/, __spreadArray([], __read(dict), false)];
103
+ }
104
+ });
105
+ }); };
106
+ var emplace = function (filter) {
107
+ return function (input) {
108
+ return function (closure) { return __awaiter(_this, void 0, void 0, function () {
109
+ var input_1, input_1_1, pattern, _a, _b, file, stats, e_1_1, e_2_1;
110
+ var e_2, _c, e_1, _d;
111
+ return __generator(this, function (_e) {
112
+ switch (_e.label) {
113
+ case 0:
114
+ _e.trys.push([0, 14, 15, 16]);
115
+ input_1 = __values(input), input_1_1 = input_1.next();
116
+ _e.label = 1;
117
+ case 1:
118
+ if (!!input_1_1.done) return [3 /*break*/, 13];
119
+ pattern = input_1_1.value;
120
+ _e.label = 2;
121
+ case 2:
122
+ _e.trys.push([2, 10, 11, 12]);
123
+ e_1 = void 0;
124
+ return [4 /*yield*/, _Glob(path_1.default.resolve(pattern))];
125
+ case 3:
126
+ _a = (__values.apply(void 0, [_e.sent()])), _b = _a.next();
127
+ _e.label = 4;
128
+ case 4:
129
+ if (!!_b.done) return [3 /*break*/, 9];
130
+ file = _b.value;
131
+ return [4 /*yield*/, fs_1.default.promises.stat(file)];
132
+ case 5:
133
+ stats = _e.sent();
134
+ if (!(stats.isDirectory() === true)) return [3 /*break*/, 7];
135
+ return [4 /*yield*/, iterate(filter)(closure)(file)];
136
+ case 6:
137
+ _e.sent();
138
+ return [3 /*break*/, 8];
139
+ case 7:
140
+ if (stats.isFile() && filter(file))
141
+ closure(file);
142
+ _e.label = 8;
143
+ case 8:
144
+ _b = _a.next();
145
+ return [3 /*break*/, 4];
146
+ case 9: return [3 /*break*/, 12];
147
+ case 10:
148
+ e_1_1 = _e.sent();
149
+ e_1 = { error: e_1_1 };
150
+ return [3 /*break*/, 12];
151
+ case 11:
152
+ try {
153
+ if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
154
+ }
155
+ finally { if (e_1) throw e_1.error; }
156
+ return [7 /*endfinally*/];
157
+ case 12:
158
+ input_1_1 = input_1.next();
159
+ return [3 /*break*/, 1];
160
+ case 13: return [3 /*break*/, 16];
161
+ case 14:
162
+ e_2_1 = _e.sent();
163
+ e_2 = { error: e_2_1 };
164
+ return [3 /*break*/, 16];
165
+ case 15:
166
+ try {
167
+ if (input_1_1 && !input_1_1.done && (_c = input_1.return)) _c.call(input_1);
168
+ }
169
+ finally { if (e_2) throw e_2.error; }
170
+ return [7 /*endfinally*/];
171
+ case 16: return [2 /*return*/];
172
+ }
173
+ });
174
+ }); };
175
+ };
176
+ };
177
+ var iterate = function (filter) {
178
+ return function (closure) {
179
+ return function (location) { return __awaiter(_this, void 0, void 0, function () {
180
+ var directory, directory_1, directory_1_1, file, next, stats, e_3_1;
181
+ var e_3, _a;
182
+ return __generator(this, function (_b) {
183
+ switch (_b.label) {
184
+ case 0: return [4 /*yield*/, fs_1.default.promises.readdir(location)];
185
+ case 1:
186
+ directory = _b.sent();
187
+ _b.label = 2;
188
+ case 2:
189
+ _b.trys.push([2, 9, 10, 11]);
190
+ directory_1 = __values(directory), directory_1_1 = directory_1.next();
191
+ _b.label = 3;
192
+ case 3:
193
+ if (!!directory_1_1.done) return [3 /*break*/, 8];
194
+ file = directory_1_1.value;
195
+ next = path_1.default.resolve("".concat(location, "/").concat(file));
196
+ return [4 /*yield*/, fs_1.default.promises.stat(next)];
197
+ case 4:
198
+ stats = _b.sent();
199
+ if (!(stats.isDirectory() === true)) return [3 /*break*/, 6];
200
+ return [4 /*yield*/, iterate(filter)(closure)(next)];
201
+ case 5:
202
+ _b.sent();
203
+ return [3 /*break*/, 7];
204
+ case 6:
205
+ if (stats.isFile() && filter(next))
206
+ closure(next);
207
+ _b.label = 7;
208
+ case 7:
209
+ directory_1_1 = directory_1.next();
210
+ return [3 /*break*/, 3];
211
+ case 8: return [3 /*break*/, 11];
212
+ case 9:
213
+ e_3_1 = _b.sent();
214
+ e_3 = { error: e_3_1 };
215
+ return [3 /*break*/, 11];
216
+ case 10:
217
+ try {
218
+ if (directory_1_1 && !directory_1_1.done && (_a = directory_1.return)) _a.call(directory_1);
219
+ }
220
+ finally { if (e_3) throw e_3.error; }
221
+ return [7 /*endfinally*/];
222
+ case 11: return [2 /*return*/];
223
+ }
224
+ });
225
+ }); };
226
+ };
227
+ };
228
+ var _Glob = function (pattern) {
229
+ return new Promise(function (resolve, reject) {
230
+ (0, glob_1.default)(pattern, function (err, matches) {
231
+ if (err)
232
+ reject(err);
233
+ else
234
+ resolve(matches.map(function (str) { return path_1.default.resolve(str); }));
235
+ });
236
+ });
237
+ };
238
+ })(SourceFinder = exports.SourceFinder || (exports.SourceFinder = {}));
239
+ //# sourceMappingURL=SourceFinder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SourceFinder.js","sourceRoot":"","sources":["../../src/utils/SourceFinder.ts"],"names":[],"mappings":"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"}
package/package.json CHANGED
@@ -1,20 +1,18 @@
1
1
  {
2
2
  "name": "@nestia/core",
3
- "version": "1.1.1",
3
+ "version": "1.1.2-dev.20230503-2",
4
4
  "description": "Super-fast validation decorators of NestJS",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "scripts": {
8
8
  "build": "rimraf lib && tsc",
9
- "build:test": "rimraf bin && tsc -p test/tsconfig.json",
10
9
  "dev": "npm run build -- --watch",
11
10
  "eslint": "eslint ./**/*.ts",
12
11
  "eslint:fix": "eslint ./**/*.ts --fix",
13
- "package:latest": "npm run build && npm run build:test && npm run test && npm publish --access public",
12
+ "package:latest": "npm run build && npm publish --access public",
14
13
  "package:next": "npm run package:latest -- --tag next",
15
14
  "prepare": "ts-patch install",
16
- "prettier": "prettier ./**/*.ts --write",
17
- "test": "node bin/test"
15
+ "prettier": "prettier ./**/*.ts --write"
18
16
  },
19
17
  "repository": {
20
18
  "type": "git",
@@ -41,6 +39,7 @@
41
39
  "@nestjs/core": ">= 7.0.1",
42
40
  "@nestjs/platform-express": ">= 7.0.1",
43
41
  "detect-ts-node": "^1.0.5",
42
+ "glob": "^7.2.0",
44
43
  "raw-body": ">= 2.0.0",
45
44
  "reflect-metadata": ">= 0.1.12",
46
45
  "rxjs": ">= 6.0.0",
@@ -52,6 +51,7 @@
52
51
  "devDependencies": {
53
52
  "@trivago/prettier-plugin-sort-imports": "^4.0.0",
54
53
  "@types/express": "^4.17.15",
54
+ "@types/glob": "^7.2.0",
55
55
  "@types/inquirer": "^9.0.3",
56
56
  "@typescript-eslint/eslint-plugin": "^5.46.1",
57
57
  "@typescript-eslint/parser": "^5.46.1",
@@ -63,9 +63,9 @@
63
63
  "prettier": "^2.8.7",
64
64
  "rimraf": "^3.0.2",
65
65
  "ts-node": "^10.9.1",
66
- "ts-patch": "3.0.0-beta3",
66
+ "ts-patch": "^2.1.0",
67
67
  "tstl": "^2.5.13",
68
- "typescript": "^5.0.4",
68
+ "typescript": "^4.9.5",
69
69
  "typescript-transform-paths": "^3.4.6"
70
70
  },
71
71
  "files": [
@@ -25,7 +25,7 @@ export namespace DynamicModule {
25
25
  * @returns module instance
26
26
  */
27
27
  export async function mount(
28
- path: string,
28
+ path: string | string[] | { include: string[]; exclude?: string[] },
29
29
  metadata: Omit<ModuleMetadata, "controllers"> = {},
30
30
  ): Promise<object> {
31
31
  // LOAD CONTROLLERS
@@ -64,7 +64,7 @@ export namespace EncryptedModule {
64
64
  * @returns Class decorated module instance
65
65
  */
66
66
  export async function dynamic(
67
- path: string,
67
+ path: string | string[] | { include: string[]; exclude?: string[] },
68
68
  password: IEncryptionPassword | IEncryptionPassword.Closure,
69
69
  options: Omit<Parameters<typeof Module>[0], "controllers"> = {},
70
70
  ): Promise<object> {
@@ -40,10 +40,7 @@ export function TypedParam(
40
40
  type?: "boolean" | "number" | "string" | "uuid",
41
41
  nullable?: false | true,
42
42
  ): ParameterDecorator {
43
- return createParamDecorator(function TypedParam(
44
- {}: any,
45
- ctx: ExecutionContext,
46
- ) {
43
+ const TypedParam = ({}: any, ctx: ExecutionContext) => {
47
44
  const request: express.Request = ctx.switchToHttp().getRequest();
48
45
  const str: string = request.params[name];
49
46
 
@@ -69,7 +66,11 @@ export function TypedParam(
69
66
  );
70
67
  return str;
71
68
  } else return str;
72
- })(name);
69
+ };
70
+
71
+ (TypedParam as any).nullable = !!nullable;
72
+ (TypedParam as any).type = type;
73
+ return createParamDecorator(TypedParam)(name);
73
74
  }
74
75
 
75
76
  const UUID_PATTERN =
@@ -3,6 +3,6 @@
3
3
  */
4
4
  export function TransformError(method: string): Error {
5
5
  return new Error(
6
- `Error on nestia.core.${method}(): no transform has been configured. Configure "tsconfig.json" file following [Guide Documents](https://github.com/samchon/nestia/wiki/Setup#tsconfigjson).`,
6
+ `Error on nestia.core.${method}(): no transform has been configured. Run "npx typia setup" command.`,
7
7
  );
8
8
  }
@@ -1,35 +1,42 @@
1
1
  import is_ts_node from "detect-ts-node";
2
- import fs from "fs";
3
2
 
4
3
  import { Creator } from "../../typings/Creator";
4
+ import { SourceFinder } from "../../utils/SourceFinder";
5
5
 
6
- export async function load_controllers(
7
- path: string,
8
- ): Promise<Creator<object>[]> {
9
- const output: any[] = [];
10
- await iterate(output, path);
11
- return output;
12
- }
13
-
14
- async function iterate(
15
- controllers: Creator<object>[],
16
- path: string,
17
- ): Promise<void> {
18
- const directory: string[] = await fs.promises.readdir(path);
19
- for (const file of directory) {
20
- const current: string = `${path}/${file}`;
21
- const stats: fs.Stats = await fs.promises.lstat(current);
6
+ export const load_controllers = async (
7
+ path: string | string[] | { include: string[]; exclude?: string[] },
8
+ ): Promise<Creator<object>[]> => {
9
+ const sources: string[] = await SourceFinder.find({
10
+ include: Array.isArray(path)
11
+ ? path
12
+ : typeof path === "object"
13
+ ? path.include
14
+ : [path],
15
+ exclude:
16
+ typeof path === "object" && !Array.isArray(path)
17
+ ? path.exclude ?? []
18
+ : [],
19
+ filter:
20
+ EXTENSION === "ts"
21
+ ? (file) =>
22
+ file.substring(file.length - 3) === ".ts" &&
23
+ file.substring(file.length - 5) !== ".d.ts"
24
+ : (flle) => flle.substring(flle.length - 3) === ".js",
25
+ });
26
+ return mount(sources);
27
+ };
22
28
 
23
- if (stats.isDirectory() === true) await iterate(controllers, current);
24
- else if (file.substring(file.length - 3) === `.${EXTENSION}`) {
25
- const external: any = await import(current);
26
- for (const key in external) {
27
- const instance: Creator<object> = external[key];
28
- if (Reflect.getMetadata("path", instance) !== undefined)
29
- controllers.push(instance);
30
- }
29
+ async function mount(sources: string[]): Promise<any[]> {
30
+ const controllers: any[] = [];
31
+ for (const file of sources) {
32
+ const external: any = await import(file);
33
+ for (const key in external) {
34
+ const instance: Creator<object> = external[key];
35
+ if (Reflect.getMetadata("path", instance) !== undefined)
36
+ controllers.push(instance);
31
37
  }
32
38
  }
39
+ return controllers;
33
40
  }
34
41
 
35
42
  const EXTENSION = is_ts_node ? "ts" : "js";
@@ -0,0 +1,60 @@
1
+ import fs from "fs";
2
+ import glob from "glob";
3
+ import path from "path";
4
+
5
+ export namespace SourceFinder {
6
+ export const find = async (props: IProps): Promise<string[]> => {
7
+ const dict: Set<string> = new Set();
8
+
9
+ await emplace(props.filter)(props.include)((str) => dict.add(str));
10
+ if (props.exclude?.length)
11
+ await emplace(props.filter)(props.exclude)((str) =>
12
+ dict.delete(str),
13
+ );
14
+
15
+ return [...dict];
16
+ };
17
+
18
+ const emplace =
19
+ (filter: (file: string) => boolean) =>
20
+ (input: string[]) =>
21
+ async (closure: (location: string) => void): Promise<void> => {
22
+ for (const pattern of input) {
23
+ for (const file of await _Glob(path.resolve(pattern))) {
24
+ const stats: fs.Stats = await fs.promises.stat(file);
25
+ if (stats.isDirectory() === true)
26
+ await iterate(filter)(closure)(file);
27
+ else if (stats.isFile() && filter(file)) closure(file);
28
+ }
29
+ }
30
+ };
31
+
32
+ const iterate =
33
+ (filter: (location: string) => boolean) =>
34
+ (closure: (location: string) => void) =>
35
+ async (location: string): Promise<void> => {
36
+ const directory: string[] = await fs.promises.readdir(location);
37
+ for (const file of directory) {
38
+ const next: string = path.resolve(`${location}/${file}`);
39
+ const stats: fs.Stats = await fs.promises.stat(next);
40
+
41
+ if (stats.isDirectory() === true)
42
+ await iterate(filter)(closure)(next);
43
+ else if (stats.isFile() && filter(next)) closure(next);
44
+ }
45
+ };
46
+
47
+ const _Glob = (pattern: string): Promise<string[]> =>
48
+ new Promise((resolve, reject) => {
49
+ glob(pattern, (err, matches) => {
50
+ if (err) reject(err);
51
+ else resolve(matches.map((str) => path.resolve(str)));
52
+ });
53
+ });
54
+ }
55
+
56
+ interface IProps {
57
+ exclude?: string[];
58
+ include: string[];
59
+ filter: (location: string) => boolean;
60
+ }