@nestia/migrate 0.1.5 → 0.1.6
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/lib/bundles/TEMPLATE.js +4 -4
- package/lib/bundles/TEMPLATE.js.map +1 -1
- package/lib/programmers/ControllerProgrammer.js +14 -4
- package/lib/programmers/ControllerProgrammer.js.map +1 -1
- package/lib/programmers/RouteProgrammer.js +21 -8
- package/lib/programmers/RouteProgrammer.js.map +1 -1
- package/lib/structures/IMigrateRoute.d.ts +6 -2
- package/package.json +14 -5
- package/src/bundles/TEMPLATE.ts +4 -4
- package/src/programmers/ControllerProgrammer.ts +17 -4
- package/src/programmers/RouteProgrammer.ts +32 -11
- package/src/structures/IMigrateRoute.ts +6 -2
- package/lib/test/index.d.ts +0 -1
- package/lib/test/index.js +0 -33
- package/lib/test/index.js.map +0 -1
- package/src/test/index.ts +0 -32
package/lib/bundles/TEMPLATE.js
CHANGED
@@ -50,7 +50,7 @@ exports.TEMPLATE = [
|
|
50
50
|
{
|
51
51
|
"location": "",
|
52
52
|
"file": "package.json",
|
53
|
-
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"----------------------------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.4.
|
53
|
+
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"----------------------------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.4.9\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^3.3.1\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^5.40.0\",\r\n \"@typescript-eslint/parser\": \"^5.40.0\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"eslint-plugin-deprecation\": \"^1.4.1\",\r\n \"nestia\": \"^4.3.2\",\r\n \"prettier\": \"^2.7.1\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.0\",\r\n \"typescript\": \"^5.1.3\",\r\n \"typescript-transform-paths\": \"^3.4.6\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^1.4.3\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^4.1.4\",\r\n \"uuid\": \"^9.0.0\"\r\n },\r\n \"stackblitz\": {\r\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\r\n }\r\n}"
|
54
54
|
},
|
55
55
|
{
|
56
56
|
"location": "/packages/api",
|
@@ -60,7 +60,7 @@ exports.TEMPLATE = [
|
|
60
60
|
{
|
61
61
|
"location": "/packages/api",
|
62
62
|
"file": "package.json",
|
63
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.
|
63
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.4\"\r\n }\r\n}\r\n"
|
64
64
|
},
|
65
65
|
{
|
66
66
|
"location": "/packages/api",
|
@@ -85,12 +85,12 @@ exports.TEMPLATE = [
|
|
85
85
|
{
|
86
86
|
"location": "/src",
|
87
87
|
"file": "Backend.ts",
|
88
|
-
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(
|
88
|
+
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(Configuration.API_PORT());\r\n\r\n //----\r\n // POST-PROCESSES\r\n //----\r\n // INFORM TO THE PM2\r\n if (process.send) process.send(\"ready\");\r\n\r\n // WHEN KILL COMMAND COMES\r\n process.on(\"SIGINT\", async () => {\r\n await this.close();\r\n process.exit(0);\r\n });\r\n }\r\n\r\n public async close(): Promise<void> {\r\n if (this.application_ === undefined) return;\r\n\r\n // DO CLOSE\r\n await this.application_.close();\r\n delete this.application_;\r\n }\r\n}\r\n"
|
89
89
|
},
|
90
90
|
{
|
91
91
|
"location": "/src",
|
92
92
|
"file": "Configuration.ts",
|
93
|
-
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT =
|
93
|
+
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT = () => 37001;\r\n\r\n export const ROOT = __filename.includes(\r\n path.join(\"bin\", \"src\", \"ShoppingConfiguration\"),\r\n )\r\n ? path.resolve(__dirname + \"/../..\")\r\n : path.resolve(__dirname + \"/..\");\r\n}\r\n"
|
94
94
|
},
|
95
95
|
{
|
96
96
|
"location": "/src/executable",
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACpB;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,6lCAA6lC;KAC3mC;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,qtBAAqtB;KACnuB;IACD;QACI,UAAU,EAAE,oBAAoB;QAChC,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,+lBAA+lB;KAC7mB;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,sFAAsF;KACpG;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,iBAAiB;QACzB,SAAS,EAAE,iIAAiI;KAC/I;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,isBAAisB;KAC/sB;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,mQAAmQ;KACjR;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,inCAAinC;KAC/nC;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,kBAAkB;QAC1B,SAAS,EAAE,4hBAA4hB;KAC1iB;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,krFAAkrF;KAChsF;IACD;QACI,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,8mCAA8mC;KAC5nC;IACD;QACI,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,cAAc;QACtB,SAAS,EAAE,uoBAAuoB;KACrpB;IACD;QACI,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,gsEAAgsE;KAC9sE;IACD;QACI,UAAU,EAAE,eAAe;QAC3B,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,+YAA+Y;KAC7Z;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,oBAAoB;QAC5B,SAAS,EAAE,sdAAsd;KACpe;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,k8MAAk8M;KACh9M;IACD;QACI,UAAU,EAAE,MAAM;QAClB,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,
|
1
|
+
{"version":3,"file":"TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,QAAQ,GAAG;IACpB;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,6lCAA6lC;KAC3mC;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,gBAAgB;QACxB,SAAS,EAAE,qtBAAqtB;KACnuB;IACD;QACI,UAAU,EAAE,oBAAoB;QAChC,MAAM,EAAE,WAAW;QACnB,SAAS,EAAE,+lBAA+lB;KAC7mB;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,YAAY;QACpB,SAAS,EAAE,sFAAsF;KACpG;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,iBAAiB;QACzB,SAAS,EAAE,iIAAiI;KAC/I;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,aAAa;QACrB,SAAS,EAAE,isBAAisB;KAC/sB;IACD;QACI,UAAU,EAAE,UAAU;QACtB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,mQAAmQ;KACjR;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,SAAS;QACjB,SAAS,EAAE,inCAAinC;KAC/nC;IACD;QACI,UAAU,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AAE,OAAO;QACnB,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,i1CAAi1C;KAC/1C;IACD;QACI,UAAU,EAAE,OAAO;QACnB,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,yJAAyJ;KACvK;IACD;QACI,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,y8XAAy8X;KACv9X;CACJ,CAAA"}
|
@@ -88,6 +88,7 @@ var ControllerProgrammer;
|
|
88
88
|
}
|
89
89
|
};
|
90
90
|
ControllerProgrammer.write = (controller) => {
|
91
|
+
var _a;
|
91
92
|
const references = [];
|
92
93
|
const body = [
|
93
94
|
`@Controller(${JSON.stringify(controller.path)})`,
|
@@ -100,18 +101,27 @@ var ControllerProgrammer;
|
|
100
101
|
.join("\n\n"),
|
101
102
|
`}`,
|
102
103
|
].join("\n");
|
104
|
+
const core = controller.routes.some((r) => r.body !== null ||
|
105
|
+
r.response === null ||
|
106
|
+
r.response.type === "application/json");
|
103
107
|
const typia = controller.routes.some((m) => m.response !== null);
|
104
|
-
const
|
108
|
+
const common = new Set(["Controller"]);
|
109
|
+
for (const r of controller.routes)
|
110
|
+
if (((_a = r.response) === null || _a === void 0 ? void 0 : _a.type) === "text/plain") {
|
111
|
+
common.add("Header");
|
112
|
+
common.add(StringUtil_1.StringUtil.capitalize(r.method));
|
113
|
+
}
|
114
|
+
const dtoImports = [
|
105
115
|
...new Set(references.map((r) => r.$ref
|
106
116
|
.replace("#/components/schemas/", "")
|
107
117
|
.split(".")[0])),
|
108
118
|
].map((ref) => `import { ${ref} } from "${"../".repeat(StringUtil_1.StringUtil.split(controller.location).length - 1)}api/structures/${ref}"`);
|
109
119
|
return [
|
110
|
-
`import core from "@nestia/core"
|
111
|
-
`import {
|
120
|
+
...(core ? [`import core from "@nestia/core";`] : []),
|
121
|
+
`import { ${[...common].join(", ")} } from "@nestjs/common";`,
|
112
122
|
...(typia ? [`import typia from "typia";`] : []),
|
113
123
|
"",
|
114
|
-
...(
|
124
|
+
...(dtoImports.length ? [...dtoImports, ""] : []),
|
115
125
|
body,
|
116
126
|
].join("\n");
|
117
127
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ControllerProgrammer.js","sourceRoot":"","sources":["../../src/programmers/ControllerProgrammer.ts"],"names":[],"mappings":";;;AAIA,8CAA2C;AAC3C,oDAAiD;AACjD,uDAAoD;AAEpD,IAAiB,oBAAoB,
|
1
|
+
{"version":3,"file":"ControllerProgrammer.js","sourceRoot":"","sources":["../../src/programmers/ControllerProgrammer.ts"],"names":[],"mappings":";;;AAIA,8CAA2C;AAC3C,oDAAiD;AACjD,uDAAoD;AAEpD,IAAiB,oBAAoB,CAmKpC;AAnKD,WAAiB,oBAAoB;IACpB,4BAAO,GAAG,CAAC,OAAiB,EAAwB,EAAE;QAC/D,MAAM,IAAI,GAAiC,IAAI,GAAG,EAAE,CAAC;QAErD,gBAAgB;QAChB,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC5D,sBAAsB;YACtB,MAAM,QAAQ,GAAW,uBAAU,CAAC,KAAK,CAAC,IAAI,CAAC;iBAC1C,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC;iBAC/B,IAAI,CAAC,GAAG,CAAC,CAAC;YACf,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,QAAQ,CAAC;gBAAE,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;YAEpE,sCAAsC;YACtC,MAAM,MAAM,GAAoB,iBAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CACxD,GAAG,EAAE,CAAC,EAAE,CACX,CAAC;YACF,KAAK,MAAM,CAAC,MAAM,EAAE,KAAK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,CAAC,EAAE,EAAE,CACF,CAAC,CAAC,IAAI;iBACD,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC;iBACpC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACzB,CACJ;SACJ,CAAC,GAAG,CACD,CAAC,GAAG,EAAE,EAAE,CACJ,YAAY,GAAG,YAAY,KAAK,CAAC,MAAM,CACnC,uBAAU,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,CACnD,kBAAkB,GAAG,GAAG,CAChC,CAAC;QAEF,OAAO;YACH,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,kCAAkC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,YAAY,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,2BAA2B;YAC7D,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAChD,EAAE;YACF,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACjD,IAAI;SACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC;AACN,CAAC,EAnKgB,oBAAoB,oCAApB,oBAAoB,QAmKpC"}
|
@@ -10,8 +10,10 @@ var RouteProgrammer;
|
|
10
10
|
var _a, _b, _c;
|
11
11
|
const body = emplaceBodySchema(emplaceReference(swagger)("body"))((_a = route.requestBody) === null || _a === void 0 ? void 0 : _a.content);
|
12
12
|
const response = emplaceBodySchema(emplaceReference(swagger)("response"))((_c = ((_b = route.responses["200"]) !== null && _b !== void 0 ? _b : route.responses["201"])) === null || _c === void 0 ? void 0 : _c.content);
|
13
|
-
if (body === false || response === false)
|
13
|
+
if (body === false || response === false) {
|
14
|
+
console.log(`Failed to migrate ${props.method.toUpperCase()} ${props.path}: @nestia/migrate supports only application/json or text/plain format yet.`);
|
14
15
|
return null;
|
16
|
+
}
|
15
17
|
const [headers, query] = ["header", "query"].map((type) => {
|
16
18
|
const parameters = route.parameters.filter((p) => p.in === type);
|
17
19
|
if (parameters.length === 0)
|
@@ -135,10 +137,15 @@ var RouteProgrammer;
|
|
135
137
|
return null;
|
136
138
|
else if (content["application/json"]) {
|
137
139
|
const schema = content["application/json"].schema;
|
138
|
-
return
|
140
|
+
return {
|
141
|
+
type: "application/json",
|
142
|
+
schema: isNotObjectLiteral(schema)
|
143
|
+
? schema
|
144
|
+
: emplacer(schema),
|
145
|
+
};
|
139
146
|
}
|
140
147
|
else if (content["text/plain"])
|
141
|
-
return { type: "string" };
|
148
|
+
return { type: "text/plain", schema: { type: "string" } };
|
142
149
|
return false;
|
143
150
|
};
|
144
151
|
const emplaceReference = (swagger) => (name) => (schema) => {
|
@@ -149,9 +156,13 @@ var RouteProgrammer;
|
|
149
156
|
return { $ref: `#/components/schemas/${name}` };
|
150
157
|
};
|
151
158
|
RouteProgrammer.write = (references) => (route) => {
|
159
|
+
var _a;
|
152
160
|
const output = route.response
|
153
|
-
? SchemaProgrammer_1.SchemaProgrammer.write(references)(route.response)
|
161
|
+
? SchemaProgrammer_1.SchemaProgrammer.write(references)(route.response.schema)
|
154
162
|
: "void";
|
163
|
+
const decorator = ((_a = route.body) === null || _a === void 0 ? void 0 : _a.type) === "text/plain"
|
164
|
+
? [`@Header("Content-Type", "text/plain")`, `@`].join("\n")
|
165
|
+
: "@core.TypedRoute.";
|
155
166
|
const content = [
|
156
167
|
...(route.description
|
157
168
|
? [
|
@@ -162,7 +173,7 @@ var RouteProgrammer;
|
|
162
173
|
" */",
|
163
174
|
]
|
164
175
|
: []),
|
165
|
-
|
176
|
+
`${decorator}${StringUtil_1.StringUtil.capitalize(route.method)}${route.path.length ? `(${JSON.stringify(route.path)})` : "()"}`,
|
166
177
|
`public async ${route.name}(`,
|
167
178
|
...route.parameters.map((p) => ` ${writeParameter(p)},`),
|
168
179
|
...(route.query
|
@@ -171,9 +182,11 @@ var RouteProgrammer;
|
|
171
182
|
]
|
172
183
|
: []),
|
173
184
|
...(route.body
|
174
|
-
?
|
175
|
-
|
176
|
-
|
185
|
+
? route.body.type === "application/json"
|
186
|
+
? [
|
187
|
+
` @core.TypedBody() body: ${SchemaProgrammer_1.SchemaProgrammer.write(references)(route.body.schema)},`,
|
188
|
+
]
|
189
|
+
: [` @core.PlainBody() body: string,`]
|
177
190
|
: []),
|
178
191
|
`): Promise<${output}> {`,
|
179
192
|
...route.parameters.map((p) => ` ${StringUtil_1.StringUtil.normalize(p.key)};`),
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"RouteProgrammer.js","sourceRoot":"","sources":["../../src/programmers/RouteProgrammer.ts"],"names":[],"mappings":";;;AAIA,8DAA2D;AAC3D,oDAAiD;AACjD,yDAAsD;AAEtD,IAAiB,eAAe,
|
1
|
+
{"version":3,"file":"RouteProgrammer.js","sourceRoot":"","sources":["../../src/programmers/RouteProgrammer.ts"],"names":[],"mappings":";;;AAIA,8DAA2D;AAC3D,oDAAiD;AACjD,yDAAsD;AAEtD,IAAiB,eAAe,CAoR/B;AApRD,WAAiB,eAAe;IACf,uBAAO,GAChB,CAAC,OAAiB,EAAE,EAAE,CACtB,CAAC,KAAuC,EAAE,EAAE,CAC5C,CAAC,KAAoB,EAAwB,EAAE;;QAC3C,MAAM,IAAI,GAAG,iBAAiB,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAC7D,MAAA,KAAK,CAAC,WAAW,0CAAE,OAAO,CAC7B,CAAC;QACF,MAAM,QAAQ,GAAG,iBAAiB,CAC9B,gBAAgB,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CACxC,CAAC,MAAA,CAAC,MAAA,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,mCAAI,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,0CA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,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACpC,GAAG,CAAC,MAAM,KAAK,MAAM;gBACjB,CAAC,CAAC,CAAC,2BAA2B,MAAM,MAAM,CAAC;gBAC3C,CAAC,CAAC,EAAE,CAAC;YACT,GAAG;SACN,CAAC;QACF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEN,MAAM,cAAc,GAAG,CAAC,EACpB,GAAG,EACH,MAAM,GACiB,EAAU,EAAE;QACnC,MAAM,QAAQ,GAAG,uBAAU,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,MAAM,GACR,iCAAe,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChC,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;YAClD,CAAC,CAAC,MAAM,CAAC,MAAM;YACf,CAAC,CAAC,IAAI,CAAC;QACf,OAAO,oBAAoB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAC1C,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,EAC7C,KAAK,QAAQ,KAAK,mCAAgB,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;IAC3D,CAAC,CAAC;AACN,CAAC,EApRgB,eAAe,+BAAf,eAAe,QAoR/B"}
|
@@ -6,8 +6,8 @@ export interface IMigrateRoute {
|
|
6
6
|
parameters: IMigrateRoute.IParameter[];
|
7
7
|
headers: ISwaggerSchema | null;
|
8
8
|
query: ISwaggerSchema | null;
|
9
|
-
body:
|
10
|
-
response:
|
9
|
+
body: IMigrateRoute.IBody | null;
|
10
|
+
response: IMigrateRoute.IBody | null;
|
11
11
|
description?: string;
|
12
12
|
}
|
13
13
|
export declare namespace IMigrateRoute {
|
@@ -16,4 +16,8 @@ export declare namespace IMigrateRoute {
|
|
16
16
|
schema: ISwaggerSchema;
|
17
17
|
description?: string;
|
18
18
|
}
|
19
|
+
interface IBody {
|
20
|
+
type: "text/plain" | "application/json";
|
21
|
+
schema: ISwaggerSchema;
|
22
|
+
}
|
19
23
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nestia/migrate",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.6",
|
4
4
|
"description": "Migration program from swagger to NestJS",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"typings": "lib/index.d.ts",
|
@@ -10,7 +10,8 @@
|
|
10
10
|
"scripts": {
|
11
11
|
"build": "rimraf lib && tsc",
|
12
12
|
"dev": "npm run build -- --watch",
|
13
|
-
"prepare": "ts-patch install && ts-node src/executable/bundle.ts"
|
13
|
+
"prepare": "ts-patch install && ts-node src/executable/bundle.ts",
|
14
|
+
"test": "node lib/test"
|
14
15
|
},
|
15
16
|
"repository": {
|
16
17
|
"type": "git",
|
@@ -29,22 +30,30 @@
|
|
29
30
|
},
|
30
31
|
"homepage": "https://github.com/samchon/nestia#readme",
|
31
32
|
"devDependencies": {
|
33
|
+
"@nestia/core": "^1.4.3",
|
34
|
+
"@nestia/fetcher": "^1.4.0",
|
32
35
|
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
|
33
36
|
"@types/node": "^20.3.3",
|
34
37
|
"prettier": "^2.8.8",
|
35
38
|
"rimraf": "^5.0.1",
|
39
|
+
"serialize-error": "^4.1.0",
|
40
|
+
"source-map-support": "^0.5.21",
|
36
41
|
"ts-node": "^10.9.1",
|
37
42
|
"ts-patch": "^3.0.1",
|
38
|
-
"
|
43
|
+
"tstl": "^2.5.13",
|
44
|
+
"typescript": "^5.1.6",
|
45
|
+
"typescript-transform-paths": "^3.4.6"
|
39
46
|
},
|
40
47
|
"dependencies": {
|
41
|
-
"typia": "^4.1.
|
48
|
+
"typia": "^4.1.4"
|
42
49
|
},
|
43
50
|
"files": [
|
44
51
|
"lib",
|
45
52
|
"src",
|
53
|
+
"!lib/test",
|
54
|
+
"!src/test",
|
46
55
|
"package.json",
|
47
56
|
"README.md",
|
48
57
|
"LICENSE"
|
49
58
|
]
|
50
|
-
}
|
59
|
+
}
|
package/src/bundles/TEMPLATE.ts
CHANGED
@@ -47,7 +47,7 @@ export const TEMPLATE = [
|
|
47
47
|
{
|
48
48
|
"location": "",
|
49
49
|
"file": "package.json",
|
50
|
-
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"----------------------------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.4.
|
50
|
+
"content": "{\r\n \"private\": true,\r\n \"name\": \"@ORGANIZATION/PROJECT\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"Starter kit of Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"scripts\": {\r\n \"----------------------------------------------\": \"\",\r\n \"build\": \"npm run build:sdk && npm run build:main && npm run build:test\",\r\n \"build:api\": \"rimraf packages/api/lib && npm run build:sdk && tsc -p packages/api/tsconfig.json\",\r\n \"build:main\": \"rimraf lib && tsc\",\r\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\r\n \"build:swagger\": \"npx nestia swagger\",\r\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\r\n \"dev\": \"npm run build:test -- --watch\",\r\n \"eslint\": \"eslint src && eslint test\",\r\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\r\n \"prepare\": \"ts-patch install\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"-----------------------------------------------\": \"\",\r\n \"start\": \"node lib/executable/server\",\r\n \"test\": \"node bin/test\",\r\n \"------------------------------------------------\": \"\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"keywords\": [\r\n \"nestia\",\r\n \"template\",\r\n \"boilerplate\"\r\n ],\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.3.6\",\r\n \"@nestia/sdk\": \"^1.4.9\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^3.3.1\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^5.40.0\",\r\n \"@typescript-eslint/parser\": \"^5.40.0\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"eslint-plugin-deprecation\": \"^1.4.1\",\r\n \"nestia\": \"^4.3.2\",\r\n \"prettier\": \"^2.7.1\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.0\",\r\n \"typescript\": \"^5.1.3\",\r\n \"typescript-transform-paths\": \"^3.4.6\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^1.4.3\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^4.1.4\",\r\n \"uuid\": \"^9.0.0\"\r\n },\r\n \"stackblitz\": {\r\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test\"\r\n }\r\n}"
|
51
51
|
},
|
52
52
|
{
|
53
53
|
"location": "/packages/api",
|
@@ -57,7 +57,7 @@ export const TEMPLATE = [
|
|
57
57
|
{
|
58
58
|
"location": "/packages/api",
|
59
59
|
"file": "package.json",
|
60
|
-
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.
|
60
|
+
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.0.0\",\r\n \"description\": \"API for PROJECT\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-template\"\r\n },\r\n \"author\": \"AUTHOR\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia-template/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-template#readme\",\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^1.4.0\",\r\n \"typia\": \"^4.1.4\"\r\n }\r\n}\r\n"
|
61
61
|
},
|
62
62
|
{
|
63
63
|
"location": "/packages/api",
|
@@ -82,12 +82,12 @@ export const TEMPLATE = [
|
|
82
82
|
{
|
83
83
|
"location": "/src",
|
84
84
|
"file": "Backend.ts",
|
85
|
-
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(
|
85
|
+
"content": "import core from \"@nestia/core\";\r\nimport { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { Configuration } from \"./Configuration\";\r\n\r\nexport class Backend {\r\n private application_?: NestFastifyApplication;\r\n\r\n public async open(): Promise<void> {\r\n //----\r\n // OPEN THE BACKEND SERVER\r\n //----\r\n // MOUNT CONTROLLERS\r\n this.application_ = await NestFactory.create(\r\n await core.DynamicModule.mount(__dirname + \"/controllers\"),\r\n new FastifyAdapter(),\r\n { logger: false },\r\n );\r\n\r\n // DO OPEN\r\n this.application_.enableCors();\r\n await this.application_.listen(Configuration.API_PORT());\r\n\r\n //----\r\n // POST-PROCESSES\r\n //----\r\n // INFORM TO THE PM2\r\n if (process.send) process.send(\"ready\");\r\n\r\n // WHEN KILL COMMAND COMES\r\n process.on(\"SIGINT\", async () => {\r\n await this.close();\r\n process.exit(0);\r\n });\r\n }\r\n\r\n public async close(): Promise<void> {\r\n if (this.application_ === undefined) return;\r\n\r\n // DO CLOSE\r\n await this.application_.close();\r\n delete this.application_;\r\n }\r\n}\r\n"
|
86
86
|
},
|
87
87
|
{
|
88
88
|
"location": "/src",
|
89
89
|
"file": "Configuration.ts",
|
90
|
-
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT =
|
90
|
+
"content": "import path from \"path\";\r\n\r\nexport namespace Configuration {\r\n export const API_PORT = () => 37001;\r\n\r\n export const ROOT = __filename.includes(\r\n path.join(\"bin\", \"src\", \"ShoppingConfiguration\"),\r\n )\r\n ? path.resolve(__dirname + \"/../..\")\r\n : path.resolve(__dirname + \"/..\");\r\n}\r\n"
|
91
91
|
},
|
92
92
|
{
|
93
93
|
"location": "/src/executable",
|
@@ -128,10 +128,23 @@ export namespace ControllerProgrammer {
|
|
128
128
|
`}`,
|
129
129
|
].join("\n");
|
130
130
|
|
131
|
+
const core: boolean = controller.routes.some(
|
132
|
+
(r) =>
|
133
|
+
r.body !== null ||
|
134
|
+
r.response === null ||
|
135
|
+
r.response.type === "application/json",
|
136
|
+
);
|
131
137
|
const typia: boolean = controller.routes.some(
|
132
138
|
(m) => m.response !== null,
|
133
139
|
);
|
134
|
-
const
|
140
|
+
const common: Set<string> = new Set(["Controller"]);
|
141
|
+
for (const r of controller.routes)
|
142
|
+
if (r.response?.type === "text/plain") {
|
143
|
+
common.add("Header");
|
144
|
+
common.add(StringUtil.capitalize(r.method));
|
145
|
+
}
|
146
|
+
|
147
|
+
const dtoImports: string[] = [
|
135
148
|
...new Set(
|
136
149
|
references.map(
|
137
150
|
(r) =>
|
@@ -148,11 +161,11 @@ export namespace ControllerProgrammer {
|
|
148
161
|
);
|
149
162
|
|
150
163
|
return [
|
151
|
-
`import core from "@nestia/core"
|
152
|
-
`import {
|
164
|
+
...(core ? [`import core from "@nestia/core";`] : []),
|
165
|
+
`import { ${[...common].join(", ")} } from "@nestjs/common";`,
|
153
166
|
...(typia ? [`import typia from "typia";`] : []),
|
154
167
|
"",
|
155
|
-
...(
|
168
|
+
...(dtoImports.length ? [...dtoImports, ""] : []),
|
156
169
|
body,
|
157
170
|
].join("\n");
|
158
171
|
};
|
@@ -17,7 +17,14 @@ export namespace RouteProgrammer {
|
|
17
17
|
const response = emplaceBodySchema(
|
18
18
|
emplaceReference(swagger)("response"),
|
19
19
|
)((route.responses["200"] ?? route.responses["201"])?.content);
|
20
|
-
if (body === false || response === false)
|
20
|
+
if (body === false || response === false) {
|
21
|
+
console.log(
|
22
|
+
`Failed to migrate ${props.method.toUpperCase()} ${
|
23
|
+
props.path
|
24
|
+
}: @nestia/migrate supports only application/json or text/plain format yet.`,
|
25
|
+
);
|
26
|
+
return null;
|
27
|
+
}
|
21
28
|
|
22
29
|
const [headers, query] = ["header", "query"].map((type) => {
|
23
30
|
const parameters = route.parameters.filter(
|
@@ -179,12 +186,20 @@ export namespace RouteProgrammer {
|
|
179
186
|
|
180
187
|
const emplaceBodySchema =
|
181
188
|
(emplacer: (schema: ISwaggerSchema) => ISwaggerSchema.IReference) =>
|
182
|
-
(
|
189
|
+
(
|
190
|
+
content?: ISwaggerRoute.IContent,
|
191
|
+
): false | null | IMigrateRoute.IBody => {
|
183
192
|
if (!content) return null;
|
184
193
|
else if (content["application/json"]) {
|
185
194
|
const schema = content["application/json"].schema;
|
186
|
-
return
|
187
|
-
|
195
|
+
return {
|
196
|
+
type: "application/json",
|
197
|
+
schema: isNotObjectLiteral(schema)
|
198
|
+
? schema
|
199
|
+
: emplacer(schema),
|
200
|
+
};
|
201
|
+
} else if (content["text/plain"])
|
202
|
+
return { type: "text/plain", schema: { type: "string" } };
|
188
203
|
return false;
|
189
204
|
};
|
190
205
|
|
@@ -201,8 +216,12 @@ export namespace RouteProgrammer {
|
|
201
216
|
(references: ISwaggerSchema.IReference[]) =>
|
202
217
|
(route: IMigrateRoute): string => {
|
203
218
|
const output: string = route.response
|
204
|
-
? SchemaProgrammer.write(references)(route.response)
|
219
|
+
? SchemaProgrammer.write(references)(route.response.schema)
|
205
220
|
: "void";
|
221
|
+
const decorator: string =
|
222
|
+
route.body?.type === "text/plain"
|
223
|
+
? [`@Header("Content-Type", "text/plain")`, `@`].join("\n")
|
224
|
+
: "@core.TypedRoute.";
|
206
225
|
const content: string[] = [
|
207
226
|
...(route.description
|
208
227
|
? [
|
@@ -213,7 +232,7 @@ export namespace RouteProgrammer {
|
|
213
232
|
" */",
|
214
233
|
]
|
215
234
|
: []),
|
216
|
-
|
235
|
+
`${decorator}${StringUtil.capitalize(route.method)}${
|
217
236
|
route.path.length ? `(${JSON.stringify(route.path)})` : "()"
|
218
237
|
}`,
|
219
238
|
`public async ${route.name}(`,
|
@@ -226,11 +245,13 @@ export namespace RouteProgrammer {
|
|
226
245
|
]
|
227
246
|
: []),
|
228
247
|
...(route.body
|
229
|
-
?
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
248
|
+
? route.body.type === "application/json"
|
249
|
+
? [
|
250
|
+
` @core.TypedBody() body: ${SchemaProgrammer.write(
|
251
|
+
references,
|
252
|
+
)(route.body.schema)},`,
|
253
|
+
]
|
254
|
+
: [` @core.PlainBody() body: string,`]
|
234
255
|
: []),
|
235
256
|
`): Promise<${output}> {`,
|
236
257
|
...route.parameters.map(
|
@@ -7,8 +7,8 @@ export interface IMigrateRoute {
|
|
7
7
|
parameters: IMigrateRoute.IParameter[];
|
8
8
|
headers: ISwaggerSchema | null;
|
9
9
|
query: ISwaggerSchema | null;
|
10
|
-
body:
|
11
|
-
response:
|
10
|
+
body: IMigrateRoute.IBody | null;
|
11
|
+
response: IMigrateRoute.IBody | null;
|
12
12
|
description?: string;
|
13
13
|
}
|
14
14
|
export namespace IMigrateRoute {
|
@@ -17,4 +17,8 @@ export namespace IMigrateRoute {
|
|
17
17
|
schema: ISwaggerSchema;
|
18
18
|
description?: string;
|
19
19
|
}
|
20
|
+
export interface IBody {
|
21
|
+
type: "text/plain" | "application/json";
|
22
|
+
schema: ISwaggerSchema;
|
23
|
+
}
|
20
24
|
}
|
package/lib/test/index.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/lib/test/index.js
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
-
};
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
7
|
-
const module_1 = require("../module");
|
8
|
-
const SetupWizard_1 = require("../utils/SetupWizard");
|
9
|
-
const INPUT = __dirname + "/../../assets/input";
|
10
|
-
const OUTPUT = __dirname + "/../../assets/output";
|
11
|
-
const main = () => {
|
12
|
-
if (fs_1.default.existsSync(OUTPUT))
|
13
|
-
fs_1.default.rmSync(OUTPUT, { recursive: true });
|
14
|
-
fs_1.default.mkdirSync(OUTPUT);
|
15
|
-
const directory = fs_1.default.readdirSync(INPUT);
|
16
|
-
for (const file of directory) {
|
17
|
-
const location = `${INPUT}/${file}`;
|
18
|
-
if (!location.endsWith(".json"))
|
19
|
-
continue;
|
20
|
-
const swagger = JSON.parse(fs_1.default.readFileSync(location, "utf8"));
|
21
|
-
const app = new module_1.NestiaMigrateApplication(swagger);
|
22
|
-
app.analyze();
|
23
|
-
const project = `${OUTPUT}/${file.replace(".json", "")}`;
|
24
|
-
fs_1.default.mkdirSync(project);
|
25
|
-
app.generate({
|
26
|
-
mkdir: fs_1.default.mkdirSync,
|
27
|
-
writeFile: (path, content) => fs_1.default.promises.writeFile(path, content, "utf8"),
|
28
|
-
})(project);
|
29
|
-
SetupWizard_1.SetupWizard.setup(project);
|
30
|
-
}
|
31
|
-
};
|
32
|
-
main();
|
33
|
-
//# sourceMappingURL=index.js.map
|
package/lib/test/index.js.map
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":";;;;;AAAA,4CAAoB;AAEpB,sCAA+D;AAC/D,sDAAmD;AAEnD,MAAM,KAAK,GAAG,SAAS,GAAG,qBAAqB,CAAC;AAChD,MAAM,MAAM,GAAG,SAAS,GAAG,sBAAsB,CAAC;AAElD,MAAM,IAAI,GAAG,GAAG,EAAE;IACd,IAAI,YAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,YAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAClE,YAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAErB,MAAM,SAAS,GAAa,YAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAClD,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC1B,MAAM,QAAQ,GAAW,GAAG,KAAK,IAAI,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,SAAS;QAE1C,MAAM,OAAO,GAAa,IAAI,CAAC,KAAK,CAAC,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACxE,MAAM,GAAG,GAAG,IAAI,iCAAwB,CAAC,OAAO,CAAC,CAAC;QAClD,GAAG,CAAC,OAAO,EAAE,CAAC;QAEd,MAAM,OAAO,GAAW,GAAG,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC;QACjE,YAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACtB,GAAG,CAAC,QAAQ,CAAC;YACT,KAAK,EAAE,YAAE,CAAC,SAAS;YACnB,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,CACzB,YAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;SACnD,CAAC,CAAC,OAAO,CAAC,CAAC;QACZ,yBAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC9B;AACL,CAAC,CAAC;AACF,IAAI,EAAE,CAAC"}
|
package/src/test/index.ts
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
|
3
|
-
import { ISwagger, NestiaMigrateApplication } from "../module";
|
4
|
-
import { SetupWizard } from "../utils/SetupWizard";
|
5
|
-
|
6
|
-
const INPUT = __dirname + "/../../assets/input";
|
7
|
-
const OUTPUT = __dirname + "/../../assets/output";
|
8
|
-
|
9
|
-
const main = () => {
|
10
|
-
if (fs.existsSync(OUTPUT)) fs.rmSync(OUTPUT, { recursive: true });
|
11
|
-
fs.mkdirSync(OUTPUT);
|
12
|
-
|
13
|
-
const directory: string[] = fs.readdirSync(INPUT);
|
14
|
-
for (const file of directory) {
|
15
|
-
const location: string = `${INPUT}/${file}`;
|
16
|
-
if (!location.endsWith(".json")) continue;
|
17
|
-
|
18
|
-
const swagger: ISwagger = JSON.parse(fs.readFileSync(location, "utf8"));
|
19
|
-
const app = new NestiaMigrateApplication(swagger);
|
20
|
-
app.analyze();
|
21
|
-
|
22
|
-
const project: string = `${OUTPUT}/${file.replace(".json", "")}`;
|
23
|
-
fs.mkdirSync(project);
|
24
|
-
app.generate({
|
25
|
-
mkdir: fs.mkdirSync,
|
26
|
-
writeFile: (path, content) =>
|
27
|
-
fs.promises.writeFile(path, content, "utf8"),
|
28
|
-
})(project);
|
29
|
-
SetupWizard.setup(project);
|
30
|
-
}
|
31
|
-
};
|
32
|
-
main();
|