Skip to content

Commit f01d227

Browse files
authored
Merge pull request #678 from samchon/features/allstar
Ignore wildcard URL case.
2 parents 8338336 + 5a054fe commit f01d227

File tree

15 files changed

+99
-55
lines changed

15 files changed

+99
-55
lines changed

benchmark/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"homepage": "https://nestia.io",
2626
"dependencies": {
2727
"@nestia/core": "^2.2.1-dev.20231012",
28-
"typia": "^5.2.4"
28+
"typia": "^5.2.5"
2929
},
3030
"devDependencies": {
3131
"@trivago/prettier-plugin-sort-imports": "^4.1.1",

packages/core/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nestia/core",
3-
"version": "2.3.4",
3+
"version": "0.0.0-dev.20991231",
44
"description": "Super-fast validation decorators of NestJS",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -34,7 +34,7 @@
3434
},
3535
"homepage": "https://nestia.io",
3636
"dependencies": {
37-
"@nestia/fetcher": "^2.3.4",
37+
"@nestia/fetcher": "D:\\github\\samchon\\nestia\\packages\\fetcher\\nestia-fetcher-0.0.0-dev.20991231.tgz",
3838
"@nestjs/common": ">=7.0.1",
3939
"@nestjs/core": ">=7.0.1",
4040
"@nestjs/platform-express": ">=7.0.1",
@@ -44,10 +44,10 @@
4444
"raw-body": ">=2.0.0",
4545
"reflect-metadata": ">=0.1.12",
4646
"rxjs": ">=6.0.0",
47-
"typia": "^5.2.4"
47+
"typia": "^5.2.5"
4848
},
4949
"peerDependencies": {
50-
"@nestia/fetcher": ">=2.3.4",
50+
"@nestia/fetcher": ">=0.0.0-dev.20991231",
5151
"@nestjs/common": ">=7.0.1",
5252
"@nestjs/core": ">=7.0.1",
5353
"@nestjs/platform-express": ">=7.0.1",
@@ -56,7 +56,7 @@
5656
"reflect-metadata": ">=0.1.12",
5757
"rxjs": ">=6.0.0",
5858
"typescript": ">=4.8.0 <5.3.0",
59-
"typia": ">=5.2.4 <6.0.0"
59+
"typia": ">=5.2.5 <6.0.0"
6060
},
6161
"devDependencies": {
6262
"@trivago/prettier-plugin-sort-imports": "^4.0.0",

packages/e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"ts-node": "^10.9.1",
4141
"ts-patch": "^3.0.2",
4242
"typescript": "^5.2.2",
43-
"typia": "^5.2.4"
43+
"typia": "^5.2.5"
4444
},
4545
"dependencies": {
4646
"chalk": "^4.1.2",

packages/fetcher/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nestia/fetcher",
3-
"version": "2.3.4",
3+
"version": "0.0.0-dev.20991231",
44
"description": "Fetcher library of Nestia SDK",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",

packages/migrate/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"typescript-transform-paths": "^3.4.6"
4646
},
4747
"dependencies": {
48-
"typia": "^5.2.4"
48+
"typia": "^5.2.5"
4949
},
5050
"files": [
5151
"lib",

packages/sdk/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nestia/sdk",
3-
"version": "2.3.4",
3+
"version": "0.0.0-dev.20991231",
44
"description": "Nestia SDK and Swagger generator",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -35,7 +35,7 @@
3535
},
3636
"homepage": "https://nestia.io",
3737
"dependencies": {
38-
"@nestia/fetcher": "^2.3.4",
38+
"@nestia/fetcher": "D:\\github\\samchon\\nestia\\packages\\fetcher\\nestia-fetcher-0.0.0-dev.20991231.tgz",
3939
"cli": "^1.0.1",
4040
"get-function-location": "^2.0.0",
4141
"glob": "^7.2.0",
@@ -44,18 +44,19 @@
4444
"tsconfck": "^2.0.1",
4545
"tsconfig-paths": "^4.1.1",
4646
"tstl": "^2.5.13",
47-
"typia": "^5.2.4"
47+
"typia": "^5.2.5"
4848
},
4949
"peerDependencies": {
50-
"@nestia/fetcher": ">=2.3.4",
50+
"@nestia/fetcher": ">=0.0.0-dev.20991231",
5151
"@nestjs/common": ">=7.0.1",
5252
"@nestjs/core": ">=7.0.1",
5353
"reflect-metadata": ">=0.1.12",
5454
"ts-node": ">=10.6.0",
5555
"typescript": ">=4.8.0 <5.3.0",
56-
"typia": ">=5.2.4 <6.0.0"
56+
"typia": ">=5.2.5 <6.0.0"
5757
},
5858
"devDependencies": {
59+
"@nestia/e2e": "^0.3.7",
5960
"@nestjs/common": ">= 7.0.1",
6061
"@nestjs/core": ">= 7.0.1",
6162
"@trivago/prettier-plugin-sort-imports": "^4.0.0",

packages/sdk/src/NestiaSdkApplication.ts

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class NestiaSdkApplication {
4545
await validate("sdk")(this.config.output);
4646
await validate("e2e")(this.config.e2e);
4747

48-
title("Nestia E2E Generator");
48+
print_title("Nestia E2E Generator");
4949
await this.generate(
5050
"e2e",
5151
(config) => config,
@@ -69,7 +69,7 @@ export class NestiaSdkApplication {
6969
"Error on NestiaApplication.sdk(): output directory does not exists.",
7070
);
7171

72-
title("Nestia SDK Generator");
72+
print_title("Nestia SDK Generator");
7373
await this.generate("sdk", (config) => config, SdkGenerator.generate);
7474
}
7575

@@ -89,7 +89,7 @@ export class NestiaSdkApplication {
8989
"Error on NestiaApplication.swagger(): output directory does not exists.",
9090
);
9191

92-
title("Nestia Swagger Generator");
92+
print_title("Nestia Swagger Generator");
9393
await this.generate(
9494
"swagger",
9595
(config) => config.swagger!,
@@ -112,6 +112,7 @@ export class NestiaSdkApplication {
112112
input: await ConfigAnalyzer.input(this.config),
113113
checker: null!,
114114
errors: [],
115+
warnings: [],
115116
};
116117

117118
console.log("Analyzing reflections");
@@ -170,9 +171,10 @@ export class NestiaSdkApplication {
170171

171172
// REPORT ERRORS
172173
if (project.errors.length) {
173-
report_errors(project.errors);
174+
report_errors("error")(project.errors);
174175
process.exit(-1);
175176
}
177+
if (project.warnings.length) report_errors("warning")(project.warnings);
176178

177179
// FIND IMPLICIT TYPES
178180
const implicit: IRoute[] = routeList.filter(is_implicit_return_typed);
@@ -195,7 +197,7 @@ export class NestiaSdkApplication {
195197
}
196198
}
197199

198-
const title = (str: string): void => {
200+
const print_title = (str: string): void => {
199201
console.log("-----------------------------------------------------------");
200202
console.log(` ${str}`);
201203
console.log("-----------------------------------------------------------");
@@ -217,30 +219,45 @@ const is_implicit_return_typed = (route: IRoute): boolean => {
217219
return true;
218220
};
219221

220-
const report_errors = (errors: IErrorReport[]): void => {
221-
// key: file
222-
// key: controller
223-
// key: function
224-
// value: message
225-
const map: Map<string, Map<string, Map<string, Set<string>>>> = new Map();
226-
for (const e of errors) {
227-
const file = MapUtil.take(map, e.file, () => new Map());
228-
const controller = MapUtil.take(file, e.controller, () => new Map());
229-
const func = MapUtil.take(controller, e.function, () => new Set());
230-
func.add(e.message);
231-
}
222+
const report_errors =
223+
(type: "error" | "warning") =>
224+
(errors: IErrorReport[]): void => {
225+
// key: file
226+
// key: controller
227+
// key: function
228+
// value: message
229+
const map: Map<
230+
string,
231+
Map<string, Map<string, Set<string>>>
232+
> = new Map();
233+
for (const e of errors) {
234+
const file = MapUtil.take(map, e.file, () => new Map());
235+
const controller = MapUtil.take(
236+
file,
237+
e.controller,
238+
() => new Map(),
239+
);
240+
const func = MapUtil.take(controller, e.function, () => new Set());
241+
func.add(e.message);
242+
}
232243

233-
console.log("");
234-
title("Nestia Error Report");
235-
for (const [file, cMap] of map) {
236-
for (const [controller, fMap] of cMap)
237-
for (const [func, messages] of fMap) {
238-
const location: string = path.relative(process.cwd(), file);
239-
console.log(`${location} - error on ${controller}.${func}()`);
240-
for (const msg of messages) console.log(` - ${msg}`);
241-
console.log("");
242-
}
243-
}
244-
};
244+
console.log("");
245+
print_title(`Nestia ${type[0].toUpperCase()}${type.slice(1)} Report`);
246+
for (const [file, cMap] of map) {
247+
for (const [controller, fMap] of cMap)
248+
for (const [func, messages] of fMap) {
249+
const location: string = path.relative(process.cwd(), file);
250+
console.log(
251+
`${location} - ${
252+
func !== null
253+
? `${controller}.${func}()`
254+
: controller
255+
}`,
256+
);
257+
for (const msg of messages) console.log(` - ${msg}`);
258+
console.log("");
259+
}
260+
}
261+
};
245262

246263
const VARIABLE = /[a-zA-Z_$0-9]/;

packages/sdk/src/analyses/ReflectAnalyzer.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,19 @@ export namespace ReflectAnalyzer {
9999
name,
100100
functions: [],
101101
prefixes,
102-
paths: _Get_paths(creator),
102+
paths: _Get_paths(creator).filter((str) => {
103+
if (str.includes("*") === true) {
104+
project.warnings.push({
105+
file,
106+
controller: name,
107+
function: null,
108+
message:
109+
"@nestia/sdk does not compose wildcard controller.",
110+
});
111+
return false;
112+
}
113+
return true;
114+
}),
103115
versions: _Get_versions(creator),
104116
security: _Get_securities(creator),
105117
swaggerTgas:
@@ -251,7 +263,19 @@ export namespace ReflectAnalyzer {
251263
const meta: IController.IFunction = {
252264
name,
253265
method: method === "ALL" ? "POST" : method,
254-
paths: _Get_paths(proto),
266+
paths: _Get_paths(proto).filter((str) => {
267+
if (str.includes("*") === true) {
268+
project.warnings.push({
269+
file: controller.file,
270+
controller: controller.name,
271+
function: name,
272+
message:
273+
"@nestia/sdk does not compose wildcard method.",
274+
});
275+
return false;
276+
}
277+
return true;
278+
}),
255279
versions: _Get_versions(proto),
256280
parameters,
257281
status: Reflect.getMetadata(
@@ -291,6 +315,7 @@ export namespace ReflectAnalyzer {
291315
controllerLocation,
292316
metaLocation,
293317
);
318+
if (location.includes("*")) continue;
294319

295320
// LIST UP PARAMETERS
296321
const binded: string[] = PathAnalyzer.parameters(
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export interface IErrorReport {
22
file: string;
33
controller: string;
4-
function: string;
4+
function: string | null;
55
message: string;
66
}

packages/sdk/src/structures/INestiaProject.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export interface INestiaProject {
99
input: INormalizedInput;
1010
checker: ts.TypeChecker;
1111
errors: IErrorReport[];
12+
warnings: IErrorReport[];
1213
}

0 commit comments

Comments
 (0)