Skip to content

Commit

Permalink
Fix #837: critical change from NestJS 10.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
samchon committed Mar 20, 2024
1 parent 0e18664 commit c213618
Show file tree
Hide file tree
Showing 25 changed files with 63 additions and 240 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@nestia/station",
"version": "2.5.16-dev.20240320",
"version": "2.5.16-dev.20240320-2",
"description": "Nestia station",
"main": "prettier.config.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/fetcher": "^2.5.16-dev.20240320",
"@nestia/fetcher": "D:\\github\\samchon\\nestia\\packages\\fetcher\\nestia-fetcher-2.5.16-dev.20240320.tgz",
"@nestjs/common": ">=7.0.1",
"@nestjs/core": ">=7.0.1",
"detect-ts-node": "^1.0.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
"homepage": "https://nestia.io",
"dependencies": {
"@nestia/fetcher": "^2.5.16-dev.20240320",
"@nestia/fetcher": "D:\\github\\samchon\\nestia\\packages\\fetcher\\nestia-fetcher-2.5.16-dev.20240320.tgz",
"cli": "^1.0.1",
"get-function-location": "^2.0.0",
"glob": "^7.2.0",
Expand Down
64 changes: 48 additions & 16 deletions packages/sdk/src/analyses/ReflectAnalyzer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as Constants from "@nestjs/common/constants";
import { VERSION_NEUTRAL, VersionValue } from "@nestjs/common/interfaces";
import "reflect-metadata";
import { Singleton } from "tstl";
import { equal } from "tstl/ranges";

import { IController } from "../structures/IController";
Expand Down Expand Up @@ -361,7 +362,7 @@ export namespace ReflectAnalyzer {
const typeIndex: number = Number(symbol[0]);
if (isNaN(typeIndex) === true) return null;

const type: ParamCategory | undefined = NEST_PARAMETER_TYPES[typeIndex];
const type: ParamCategory | undefined = nestParameterType.get()[typeIndex];
if (type === undefined) return null;

return {
Expand Down Expand Up @@ -452,18 +453,49 @@ const METHODS = [
"HEAD",
];

// node_modules/@nestjs/common/lib/route-paramtypes.enum.ts
const NEST_PARAMETER_TYPES = [
undefined,
undefined,
undefined,
"body",
"query",
"param",
"headers",
undefined,
undefined,
undefined,
undefined,
undefined,
] as const;
// node_modules/@nestjs/common/enums/route-paramtypes.enum.ts
const nestParameterType = new Singleton<Array<ParamCategory | undefined>>(
() => {
const { version } = require("@nestjs/common/package.json");
const [major, minor, patch] = version.split(".").map(Number);
const rawBody: boolean = [
major >= 10,
major > 10 || minor >= 3,
major > 10 ||
(major === 10 && minor > 3) ||
(major === 10 &&
minor === 3 &&
((isNaN(patch) && version.split(".")[2] >= "4") || patch >= 4)),
].every((b) => b);
return rawBody
? [
undefined,
undefined,
undefined,
"body",
"rawBody",
"query",
"param",
"headers",
undefined,
undefined,
undefined,
undefined,
undefined,
]
: [
undefined,
undefined,
undefined,
"body",
"query",
"param",
"headers",
undefined,
undefined,
undefined,
undefined,
undefined,
];
},
);
2 changes: 1 addition & 1 deletion packages/sdk/src/structures/ParamCategory.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export type ParamCategory = "param" | "query" | "body" | "headers";
export type ParamCategory = "param" | "query" | "body" | "rawBody" | "headers";
2 changes: 1 addition & 1 deletion test/features/all/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
}
],
"info": {
"version": "2.5.15",
"version": "2.5.16-dev.20240320",
"title": "@nestia/test",
"description": "Test program of Nestia",
"license": {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit c213618

Please sign in to comment.