@autobe/compiler 0.14.5 → 0.15.0
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/raw/AutoBeCompilerRealizeTemplate.js +1 -1
- package/lib/raw/AutoBeCompilerRealizeTemplate.js.map +1 -1
- package/lib/realize/AutoBeRealizeCompiler.js +1 -3
- package/lib/realize/AutoBeRealizeCompiler.js.map +1 -1
- package/lib/realize/writeRealizeControllers.d.ts +1 -1
- package/lib/realize/writeRealizeControllers.js +15 -3
- package/lib/realize/writeRealizeControllers.js.map +1 -1
- package/package.json +5 -4
- package/src/raw/AutoBeCompilerRealizeTemplate.ts +1 -1
- package/src/realize/AutoBeRealizeCompiler.ts +1 -1
- package/src/realize/writeRealizeControllers.ts +8 -3
|
@@ -6,7 +6,7 @@ exports.AutoBeCompilerRealizeTemplate = {
|
|
|
6
6
|
".gitignore": "bin/\ndist/\nlib/\nnode_modules/\n\nprisma/migrations\nprisma/schema/migrations\nprisma/bbs.db\n\n*.DS_Store\npackage-lock.json\npnpm-lock.yaml\n.npmrc",
|
|
7
7
|
"package.json": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:prisma && npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:env\": \"ts-node build/env.ts\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:prisma\": \"prisma generate --schema prisma/schema\",\n \"build:swagger\": \"nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && npm run build:env && npm run build:prisma\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:dev\": \"nest start --watch\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^7.1.1\",\n \"@nestia/e2e\": \"^7.1.1\",\n \"@nestia/sdk\": \"^7.1.1\",\n \"@nestjs/cli\": \"^11.0.7\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/bcryptjs\": \"^3.0.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/jsonwebtoken\": \"^9.0.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"fastify\": \"^5.4.0\",\n \"nestia\": \"^7.1.1\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"prisma-markdown\": \"^3.0.1\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.8.3\",\n \"typescript-transform-paths\": \"^3.5.5\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^7.1.1\",\n \"@nestia/fetcher\": \"^7.1.1\",\n \"@nestjs/common\": \"^11.1.3\",\n \"@nestjs/core\": \"^11.1.3\",\n \"@nestjs/platform-express\": \"^11.1.3\",\n \"@nestjs/platform-fastify\": \"^11.1.3\",\n \"@prisma/client\": \"^6.11.1\",\n \"bcryptjs\": \"^3.0.2\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"jsonwebtoken\": \"^9.0.2\",\n \"prisma\": \"^6.11.1\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^9.5.0\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}\n",
|
|
8
8
|
"src/MyGlobal.ts": "import { PrismaClient } from \"@prisma/client\";\nimport dotenv from \"dotenv\";\nimport dotenvExpand from \"dotenv-expand\";\nimport { Singleton } from \"tstl\";\nimport typia from \"typia\";\n\n/* eslint-disable */\nexport class MyGlobal {\n public static readonly prisma: PrismaClient = new PrismaClient();\n public static testing: boolean = false;\n public static get env(): MyGlobal.IEnvironments {\n return environments.get();\n }\n}\nexport namespace MyGlobal {\n export interface IEnvironments {\n API_PORT: `${number}`;\n\n /** JWT Secret Key. */\n JWT_SECRET_KEY: string;\n }\n}\nconst environments = new Singleton(() => {\n const env = dotenv.config();\n dotenvExpand.expand(env);\n return typia.assert<MyGlobal.IEnvironments>(process.env);\n});\n",
|
|
9
|
-
"src/providers/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"
|
|
9
|
+
"src/providers/authorize/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n",
|
|
10
10
|
"src/setup/MySetupWizard.ts": "import cp from \"child_process\";\n\nimport { MyConfiguration } from \"../MyConfiguration\";\nimport { MyGlobal } from \"../MyGlobal\";\n\nexport namespace MySetupWizard {\n export async function schema(): Promise<void> {\n if (MyGlobal.testing === false)\n throw new Error(\n \"Error on SetupWizard.schema(): unable to reset database in non-test mode.\",\n );\n const execute = (type: string) => (argv: string) =>\n cp.execSync(`npx prisma migrate ${type} --schema=prisma/schema ${argv}`, {\n stdio: \"ignore\",\n cwd: MyConfiguration.ROOT,\n });\n execute(\"reset\")(\"--force\");\n execute(\"dev\")(\"--name init\");\n }\n\n export async function seed(): Promise<void> {}\n}\n",
|
|
11
11
|
"src/util/toISOStringSafe.ts": "import { tags } from \"typia\";\n\n/**\n * Transforms a value that is either a Date or a string into an ISO 8601\n * formatted string. If it's already a string, it assumes it's already in ISO\n * format.\n */\nexport function toISOStringSafe(\n value: Date | (string & tags.Format<\"date-time\">),\n): string & tags.Format<\"date-time\"> {\n if (value instanceof Date) {\n return value.toISOString() as string & tags.Format<\"date-time\">;\n }\n return value;\n}\n",
|
|
12
12
|
"test/servant.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport { Driver, WorkerServer } from \"tgrid\";\n\nimport { MyBackend } from \"../src/MyBackend\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { IAutoBeRealizeTestConfig } from \"./autobe/compiler/IAutoBeRealizeTestConfig\";\nimport { IAutoBeRealizeTestListener } from \"./autobe/compiler/IAutoBeRealizeTestListener\";\nimport { IAutoBeRealizeTestOperation } from \"./autobe/compiler/IAutoBeRealizeTestOperation\";\nimport { IAutoBeRealizeTestResult } from \"./autobe/compiler/IAutoBeRealizeTestResult\";\nimport { IAutoBeRealizeTestService } from \"./autobe/compiler/IAutoBeRealizeTestService\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\n\nclass AutoBeRealizeTestService implements IAutoBeRealizeTestService {\n public constructor(\n private readonly listener: Driver<IAutoBeRealizeTestListener>,\n ) {}\n\n public async execute(\n config: IAutoBeRealizeTestConfig,\n ): Promise<IAutoBeRealizeTestResult> {\n const start: Date = new Date();\n const operations: IAutoBeRealizeTestOperation[] = [];\n await TestAutomation.execute({\n open: async (): Promise<MyBackend> => {\n const backend: MyBackend = new MyBackend();\n await backend.open();\n return backend;\n },\n close: (backend: MyBackend): Promise<void> => backend.close(),\n options: {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n },\n onComplete: (exec: DynamicExecutor.IExecution): void => {\n const op: IAutoBeRealizeTestOperation = {\n name: exec.name,\n location: exec.location,\n value: exec.value,\n error: exec.error,\n started_at: exec.started_at,\n completed_at: exec.completed_at,\n };\n this.listener.onOperation(op).catch(() => {});\n operations.push(op);\n },\n onReset: (): void => {\n this.listener.onReset().catch(() => {});\n },\n });\n return {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n operations,\n started_at: start.toISOString(),\n completed_at: new Date().toISOString(),\n };\n }\n}\n\nconst main = async (): Promise<void> => {\n const worker: WorkerServer<\n null,\n IAutoBeRealizeTestService,\n IAutoBeRealizeTestListener\n > = new WorkerServer();\n const listener: Driver<IAutoBeRealizeTestListener> = worker.getDriver();\n const service: AutoBeRealizeTestService = new AutoBeRealizeTestService(\n listener,\n );\n\n MyGlobal.testing = true;\n await worker.open(service);\n};\nmain().catch((error) => {\n console.log(error);\n process.exit(-1);\n});\n",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeCompilerRealizeTemplate.js","sourceRoot":"","sources":["../../src/raw/AutoBeCompilerRealizeTemplate.ts"],"names":[],"mappings":";;;AAAa,QAAA,6BAA6B,GAA2B;IACnE,YAAY,EAAE,oDAAoD;IAClE,YAAY,EAAE,yJAAyJ;IACvK,cAAc,EAAE,6lJAA6lJ;IAC7mJ,iBAAiB,EAAE,6wBAA6wB;IAChyB
|
|
1
|
+
{"version":3,"file":"AutoBeCompilerRealizeTemplate.js","sourceRoot":"","sources":["../../src/raw/AutoBeCompilerRealizeTemplate.ts"],"names":[],"mappings":";;;AAAa,QAAA,6BAA6B,GAA2B;IACnE,YAAY,EAAE,oDAAoD;IAClE,YAAY,EAAE,yJAAyJ;IACvK,cAAc,EAAE,6lJAA6lJ;IAC7mJ,iBAAiB,EAAE,6wBAA6wB;IAChyB,yCAAyC,EAAE,o3BAAo3B;IAC/5B,4BAA4B,EAAE,iuBAAiuB;IAC/vB,6BAA6B,EAAE,ydAAyd;IACxf,iBAAiB,EAAE,uqFAAuqF;IAC1rF,qDAAqD,EAAE,wlMAAwlM;IAC/oM,kDAAkD,EAAE,uoGAAuoG;IAC3rG,kDAAkD,EAAE,w6KAAw6K;IAC59K,oDAAoD,EAAE,wgKAAwgK;IAC9jK,mDAAmD,EAAE,gpKAAgpK;CACtsK,CAAC"}
|
|
@@ -20,9 +20,7 @@ class AutoBeRealizeCompiler {
|
|
|
20
20
|
this.listener = listener;
|
|
21
21
|
}
|
|
22
22
|
controller(props) {
|
|
23
|
-
return
|
|
24
|
-
return (0, writeRealizeControllers_1.writeRealizeControllers)(props);
|
|
25
|
-
});
|
|
23
|
+
return (0, writeRealizeControllers_1.writeRealizeControllers)(props);
|
|
26
24
|
}
|
|
27
25
|
test(props) {
|
|
28
26
|
return (0, testRealizeProject_1.testRealizeProject)(Object.assign(Object.assign({}, props), { files: Object.assign(Object.assign({}, props.files), AutoBeCompilerRealizeTemplate_1.AutoBeCompilerRealizeTemplate) }), this.listener.test);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoBeRealizeCompiler.js","sourceRoot":"","sources":["../../src/realize/AutoBeRealizeCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,4FAAyF;AACzF,wFAAqF;AACrF,kFAA+E;AAC/E,6DAA0D;AAC1D,uEAAoE;AAEpE,MAAa,qBAAqB;IAChC,YACmB,QAAwC;QAAxC,aAAQ,GAAR,QAAQ,CAAgC;IACxD,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoBeRealizeCompiler.js","sourceRoot":"","sources":["../../src/realize/AutoBeRealizeCompiler.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,4FAAyF;AACzF,wFAAqF;AACrF,kFAA+E;AAC/E,6DAA0D;AAC1D,uEAAoE;AAEpE,MAAa,qBAAqB;IAChC,YACmB,QAAwC;QAAxC,aAAQ,GAAR,QAAQ,CAAgC;IACxD,CAAC;IAEG,UAAU,CACf,KAAoC;QAEpC,OAAO,IAAA,iDAAuB,EAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,IAAI,CACT,KAA8B;QAE9B,OAAO,IAAA,uCAAkB,kCAElB,KAAK,KACR,KAAK,kCACA,KAAK,CAAC,KAAK,GACX,6DAA6B,MAGpC,IAAI,CAAC,QAAQ,CAAC,IAAI,CACnB,CAAC;IACJ,CAAC;IAEY,WAAW;;YACtB,qDACK,iEAA+B,GAC/B,uDAA0B,GAC1B,6DAA6B,EAChC;QACJ,CAAC;KAAA;CACF;AAjCD,sDAiCC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { IAutoBeRealizeControllerProps } from "@autobe/interface";
|
|
2
|
-
export declare const writeRealizeControllers: (props: IAutoBeRealizeControllerProps) => Record<string, string
|
|
2
|
+
export declare const writeRealizeControllers: (props: IAutoBeRealizeControllerProps) => Promise<Record<string, string>>;
|
|
@@ -1,4 +1,13 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -8,7 +17,9 @@ const NestiaMigrateNestMethodProgrammer_1 = require("@nestia/migrate/lib/program
|
|
|
8
17
|
const path_1 = __importDefault(require("path"));
|
|
9
18
|
const typescript_1 = __importDefault(require("typescript"));
|
|
10
19
|
const createMigrateApplication_1 = require("../interface/createMigrateApplication");
|
|
11
|
-
const
|
|
20
|
+
const ArrayUtil_1 = require("../utils/ArrayUtil");
|
|
21
|
+
const FilePrinter_1 = require("../utils/FilePrinter");
|
|
22
|
+
const writeRealizeControllers = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
23
|
const app = (0, createMigrateApplication_1.createMigrateApplication)(props.document);
|
|
13
24
|
const result = app.nest({
|
|
14
25
|
simulate: false,
|
|
@@ -64,7 +75,8 @@ const writeRealizeControllers = (props) => {
|
|
|
64
75
|
},
|
|
65
76
|
},
|
|
66
77
|
});
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
const entries = yield ArrayUtil_1.ArrayUtil.asyncMap(Object.entries(result).filter(([key]) => key.startsWith("src/controllers/")), (_a) => __awaiter(void 0, [_a], void 0, function* ([key, value]) { return [key, yield FilePrinter_1.FilePrinter.beautify(value)]; }));
|
|
79
|
+
return Object.fromEntries(entries);
|
|
80
|
+
});
|
|
69
81
|
exports.writeRealizeControllers = writeRealizeControllers;
|
|
70
82
|
//# sourceMappingURL=writeRealizeControllers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRealizeControllers.js","sourceRoot":"","sources":["../../src/realize/writeRealizeControllers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"writeRealizeControllers.js","sourceRoot":"","sources":["../../src/realize/writeRealizeControllers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAMA,yHAAsH;AACtH,gDAAwB;AACxB,4DAA4B;AAE5B,oFAAiF;AACjF,kDAA+C;AAC/C,sDAAmD;AAE5C,MAAM,uBAAuB,GAAG,CACrC,KAAoC,EACH,EAAE;IACnC,MAAM,GAAG,G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AU,CAAC,kBAAkB,CAAC,CACnC,EACD,KAAqB,EAAE,4CAAhB,CAAC,GAAG,EAAE,KAAK,CAAC,IAAK,OAAA,CAAC,GAAG,EAAE,MAAM,yBAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA,GAAA,CACjE,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC,CAAA,CAAC;AA7GW,QAAA,uBAAuB,2BA6GlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autobe/compiler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "AI backend server code generator",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"author": "Wrtn Technologies",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"tstl": "^3.0.0",
|
|
27
27
|
"tgrid": "^1.2.0",
|
|
28
28
|
"typia": "^9.6.0",
|
|
29
|
-
"@autobe/filesystem": "^0.
|
|
30
|
-
"@autobe/interface": "^0.
|
|
31
|
-
"@autobe/utils": "^0.
|
|
29
|
+
"@autobe/filesystem": "^0.15.0",
|
|
30
|
+
"@autobe/interface": "^0.15.0",
|
|
31
|
+
"@autobe/utils": "^0.15.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^22.15.3",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"scripts": {
|
|
81
81
|
"build": "pnpm run prebuild && rimraf lib && tsc",
|
|
82
82
|
"prebuild": "ts-node build/template.ts && ts-node build/external.ts",
|
|
83
|
+
"postbuild": "node ../../internals/config/assertBuild.js",
|
|
83
84
|
"dev": "pnpm run build --watch"
|
|
84
85
|
},
|
|
85
86
|
"typings": "lib/index.d.ts"
|
|
@@ -3,7 +3,7 @@ export const AutoBeCompilerRealizeTemplate: Record<string, string> = {
|
|
|
3
3
|
".gitignore": "bin/\ndist/\nlib/\nnode_modules/\n\nprisma/migrations\nprisma/schema/migrations\nprisma/bbs.db\n\n*.DS_Store\npackage-lock.json\npnpm-lock.yaml\n.npmrc",
|
|
4
4
|
"package.json": "{\n \"private\": true,\n \"name\": \"@ORGANIZATION/PROJECT\",\n \"version\": \"0.1.0\",\n \"description\": \"Starter kit of Nestia\",\n \"main\": \"lib/index.js\",\n \"scripts\": {\n \"benchmark\": \"node bin/test/benchmark\",\n \"test\": \"node bin/test\",\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------BUILDS------------------------\": \"\",\n \"build\": \"npm run build:prisma && npm run build:sdk && npm run build:main && npm run build:test\",\n \"build:api\": \"rimraf packages/api/lib && nestia all && rimraf packages/api/lib && tsc -p packages/api/tsconfig.json && rollup -c packages/api/rollup.config.js\",\n \"build:env\": \"ts-node build/env.ts\",\n \"build:main\": \"rimraf lib && tsc\",\n \"build:sdk\": \"rimraf src/api/functional && nestia sdk\",\n \"build:prisma\": \"prisma generate --schema prisma/schema\",\n \"build:swagger\": \"nestia swagger\",\n \"build:test\": \"rimraf bin && tsc -p test/tsconfig.json\",\n \"dev\": \"npm run build:test -- --watch\",\n \"eslint\": \"eslint src && eslint test\",\n \"eslint:fix\": \"eslint --fix src && eslint --fix test\",\n \"prepare\": \"ts-patch install && npm run build:env && npm run build:prisma\",\n \"prettier\": \"prettier src --write && prettier test --write\",\n \"------------------------WEBPACK------------------------\": \"\",\n \"webpack\": \"rimraf dist && webpack\",\n \"webpack:start\": \"cd dist && node dist/server\",\n \"webpack:test\": \"npm run webpack && node bin/test/webpack.js\",\n \"------------------------DEPLOYS------------------------\": \"\",\n \"package:api\": \"npm run build:api && cd packages/api && npm publish\",\n \"start\": \"node lib/executable/server\",\n \"start:dev\": \"nest start --watch\",\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"https://github.com/samchon/nestia-start\"\n },\n \"keywords\": [\n \"nestia\",\n \"template\",\n \"boilerplate\"\n ],\n \"author\": \"AUTHOR\",\n \"license\": \"MIT\",\n \"bugs\": {\n \"url\": \"https://github.com/samchon/nestia-start/issues\"\n },\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\n \"devDependencies\": {\n \"@autobe/interface\": \"^0.10.6\",\n \"@nestia/benchmark\": \"^7.1.1\",\n \"@nestia/e2e\": \"^7.1.1\",\n \"@nestia/sdk\": \"^7.1.1\",\n \"@nestjs/cli\": \"^11.0.7\",\n \"@rollup/plugin-terser\": \"^0.4.4\",\n \"@rollup/plugin-typescript\": \"^11.1.6\",\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\n \"@types/bcryptjs\": \"^3.0.0\",\n \"@types/cli\": \"^0.11.21\",\n \"@types/cli-progress\": \"^3.11.5\",\n \"@types/express\": \"^4.17.21\",\n \"@types/inquirer\": \"^8.2.5\",\n \"@types/jsonwebtoken\": \"^9.0.5\",\n \"@types/node\": \"^18.11.0\",\n \"@types/uuid\": \"^8.3.4\",\n \"@typescript-eslint/eslint-plugin\": \"^8.1.0\",\n \"@typescript-eslint/parser\": \"^8.1.0\",\n \"chalk\": \"^4.1.2\",\n \"cli\": \"^1.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"copy-webpack-plugin\": \"^11.0.0\",\n \"eslint-plugin-deprecation\": \"^3.0.0\",\n \"express\": \"^4.18.2\",\n \"fastify\": \"^5.4.0\",\n \"nestia\": \"^7.1.1\",\n \"prettier\": \"^3.2.4\",\n \"prettier-plugin-prisma\": \"^5.0.0\",\n \"prisma-markdown\": \"^3.0.1\",\n \"rimraf\": \"^3.0.2\",\n \"rollup\": \"^4.18.0\",\n \"source-map-support\": \"^0.5.21\",\n \"swagger-ui-express\": \"^5.0.0\",\n \"ts-loader\": \"^9.5.1\",\n \"ts-node\": \"^10.9.1\",\n \"ts-patch\": \"^3.3.0\",\n \"typescript\": \"~5.8.3\",\n \"typescript-transform-paths\": \"^3.5.5\",\n \"webpack\": \"^5.89.0\",\n \"webpack-cli\": \"^5.1.4\",\n \"write-file-webpack-plugin\": \"^4.5.1\"\n },\n \"dependencies\": {\n \"@nestia/core\": \"^7.1.1\",\n \"@nestia/fetcher\": \"^7.1.1\",\n \"@nestjs/common\": \"^11.1.3\",\n \"@nestjs/core\": \"^11.1.3\",\n \"@nestjs/platform-express\": \"^11.1.3\",\n \"@nestjs/platform-fastify\": \"^11.1.3\",\n \"@prisma/client\": \"^6.11.1\",\n \"bcryptjs\": \"^3.0.2\",\n \"commander\": \"10.0.0\",\n \"dotenv\": \"^16.3.1\",\n \"dotenv-expand\": \"^10.0.0\",\n \"inquirer\": \"8.2.5\",\n \"jsonwebtoken\": \"^9.0.2\",\n \"prisma\": \"^6.11.1\",\n \"serialize-error\": \"^4.1.0\",\n \"tgrid\": \"^1.1.0\",\n \"tstl\": \"^3.0.0\",\n \"typia\": \"^9.5.0\",\n \"uuid\": \"^9.0.0\"\n },\n \"stackblitz\": {\n \"startCommand\": \"npm run prepare && npm run build:test && npm run test -- --simultaneous 1\"\n }\n}\n",
|
|
5
5
|
"src/MyGlobal.ts": "import { PrismaClient } from \"@prisma/client\";\nimport dotenv from \"dotenv\";\nimport dotenvExpand from \"dotenv-expand\";\nimport { Singleton } from \"tstl\";\nimport typia from \"typia\";\n\n/* eslint-disable */\nexport class MyGlobal {\n public static readonly prisma: PrismaClient = new PrismaClient();\n public static testing: boolean = false;\n public static get env(): MyGlobal.IEnvironments {\n return environments.get();\n }\n}\nexport namespace MyGlobal {\n export interface IEnvironments {\n API_PORT: `${number}`;\n\n /** JWT Secret Key. */\n JWT_SECRET_KEY: string;\n }\n}\nconst environments = new Singleton(() => {\n const env = dotenv.config();\n dotenvExpand.expand(env);\n return typia.assert<MyGlobal.IEnvironments>(process.env);\n});\n",
|
|
6
|
-
"src/providers/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"
|
|
6
|
+
"src/providers/authorize/jwtAuthorize.ts": "import { ForbiddenException, UnauthorizedException } from \"@nestjs/common\";\nimport jwt from \"jsonwebtoken\";\n\nimport { MyGlobal } from \"../../MyGlobal\";\n\nexport function jwtAuthorize(props: {\n request: {\n headers: { authorization?: string };\n };\n}) {\n if (!props.request.headers.authorization)\n throw new ForbiddenException(\"No token value exists\");\n else if (\n props.request.headers.authorization.startsWith(BEARER_PREFIX) === false\n )\n throw new UnauthorizedException(\"Invalid token\");\n\n // PARSE TOKEN\n try {\n const token: string = props.request.headers.authorization.substring(\n BEARER_PREFIX.length,\n );\n\n const verified = jwt.verify(token, MyGlobal.env.JWT_SECRET_KEY);\n\n return verified;\n } catch {\n throw new UnauthorizedException(\"Invalid token\");\n }\n}\n\nconst BEARER_PREFIX = \"Bearer \";\n",
|
|
7
7
|
"src/setup/MySetupWizard.ts": "import cp from \"child_process\";\n\nimport { MyConfiguration } from \"../MyConfiguration\";\nimport { MyGlobal } from \"../MyGlobal\";\n\nexport namespace MySetupWizard {\n export async function schema(): Promise<void> {\n if (MyGlobal.testing === false)\n throw new Error(\n \"Error on SetupWizard.schema(): unable to reset database in non-test mode.\",\n );\n const execute = (type: string) => (argv: string) =>\n cp.execSync(`npx prisma migrate ${type} --schema=prisma/schema ${argv}`, {\n stdio: \"ignore\",\n cwd: MyConfiguration.ROOT,\n });\n execute(\"reset\")(\"--force\");\n execute(\"dev\")(\"--name init\");\n }\n\n export async function seed(): Promise<void> {}\n}\n",
|
|
8
8
|
"src/util/toISOStringSafe.ts": "import { tags } from \"typia\";\n\n/**\n * Transforms a value that is either a Date or a string into an ISO 8601\n * formatted string. If it's already a string, it assumes it's already in ISO\n * format.\n */\nexport function toISOStringSafe(\n value: Date | (string & tags.Format<\"date-time\">),\n): string & tags.Format<\"date-time\"> {\n if (value instanceof Date) {\n return value.toISOString() as string & tags.Format<\"date-time\">;\n }\n return value;\n}\n",
|
|
9
9
|
"test/servant.ts": "import { DynamicExecutor } from \"@nestia/e2e\";\nimport { Driver, WorkerServer } from \"tgrid\";\n\nimport { MyBackend } from \"../src/MyBackend\";\nimport { MyGlobal } from \"../src/MyGlobal\";\nimport { IAutoBeRealizeTestConfig } from \"./autobe/compiler/IAutoBeRealizeTestConfig\";\nimport { IAutoBeRealizeTestListener } from \"./autobe/compiler/IAutoBeRealizeTestListener\";\nimport { IAutoBeRealizeTestOperation } from \"./autobe/compiler/IAutoBeRealizeTestOperation\";\nimport { IAutoBeRealizeTestResult } from \"./autobe/compiler/IAutoBeRealizeTestResult\";\nimport { IAutoBeRealizeTestService } from \"./autobe/compiler/IAutoBeRealizeTestService\";\nimport { TestAutomation } from \"./helpers/TestAutomation\";\n\nclass AutoBeRealizeTestService implements IAutoBeRealizeTestService {\n public constructor(\n private readonly listener: Driver<IAutoBeRealizeTestListener>,\n ) {}\n\n public async execute(\n config: IAutoBeRealizeTestConfig,\n ): Promise<IAutoBeRealizeTestResult> {\n const start: Date = new Date();\n const operations: IAutoBeRealizeTestOperation[] = [];\n await TestAutomation.execute({\n open: async (): Promise<MyBackend> => {\n const backend: MyBackend = new MyBackend();\n await backend.open();\n return backend;\n },\n close: (backend: MyBackend): Promise<void> => backend.close(),\n options: {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n },\n onComplete: (exec: DynamicExecutor.IExecution): void => {\n const op: IAutoBeRealizeTestOperation = {\n name: exec.name,\n location: exec.location,\n value: exec.value,\n error: exec.error,\n started_at: exec.started_at,\n completed_at: exec.completed_at,\n };\n this.listener.onOperation(op).catch(() => {});\n operations.push(op);\n },\n onReset: (): void => {\n this.listener.onReset().catch(() => {});\n },\n });\n return {\n reset: config.reset ?? true,\n simultaneous: config.simultaneous ?? 1,\n operations,\n started_at: start.toISOString(),\n completed_at: new Date().toISOString(),\n };\n }\n}\n\nconst main = async (): Promise<void> => {\n const worker: WorkerServer<\n null,\n IAutoBeRealizeTestService,\n IAutoBeRealizeTestListener\n > = new WorkerServer();\n const listener: Driver<IAutoBeRealizeTestListener> = worker.getDriver();\n const service: AutoBeRealizeTestService = new AutoBeRealizeTestService(\n listener,\n );\n\n MyGlobal.testing = true;\n await worker.open(service);\n};\nmain().catch((error) => {\n console.log(error);\n process.exit(-1);\n});\n",
|
|
@@ -17,7 +17,7 @@ export class AutoBeRealizeCompiler implements IAutoBeRealizeCompiler {
|
|
|
17
17
|
private readonly listener: IAutoBeRealizeCompilerListener,
|
|
18
18
|
) {}
|
|
19
19
|
|
|
20
|
-
public
|
|
20
|
+
public controller(
|
|
21
21
|
props: IAutoBeRealizeControllerProps,
|
|
22
22
|
): Promise<Record<string, string>> {
|
|
23
23
|
return writeRealizeControllers(props);
|
|
@@ -9,10 +9,12 @@ import path from "path";
|
|
|
9
9
|
import ts from "typescript";
|
|
10
10
|
|
|
11
11
|
import { createMigrateApplication } from "../interface/createMigrateApplication";
|
|
12
|
+
import { ArrayUtil } from "../utils/ArrayUtil";
|
|
13
|
+
import { FilePrinter } from "../utils/FilePrinter";
|
|
12
14
|
|
|
13
|
-
export const writeRealizeControllers = (
|
|
15
|
+
export const writeRealizeControllers = async (
|
|
14
16
|
props: IAutoBeRealizeControllerProps,
|
|
15
|
-
): Record<string, string
|
|
17
|
+
): Promise<Record<string, string>> => {
|
|
16
18
|
const app: NestiaMigrateApplication = createMigrateApplication(
|
|
17
19
|
props.document,
|
|
18
20
|
);
|
|
@@ -111,9 +113,12 @@ export const writeRealizeControllers = (
|
|
|
111
113
|
},
|
|
112
114
|
},
|
|
113
115
|
});
|
|
114
|
-
|
|
116
|
+
|
|
117
|
+
const entries: [string, string][] = await ArrayUtil.asyncMap(
|
|
115
118
|
Object.entries(result).filter(([key]) =>
|
|
116
119
|
key.startsWith("src/controllers/"),
|
|
117
120
|
),
|
|
121
|
+
async ([key, value]) => [key, await FilePrinter.beautify(value)],
|
|
118
122
|
);
|
|
123
|
+
return Object.fromEntries(entries);
|
|
119
124
|
};
|