@nestia/migrate 0.6.3 → 0.7.0-dev.20240201
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/IMigrateConfig.d.ts +1 -0
- package/lib/MigrateApplication.d.ts +3 -15
- package/lib/MigrateApplication.js +21 -62
- package/lib/MigrateApplication.js.map +1 -1
- package/lib/bundles/NEST_TEMPLATE.d.ts +5 -0
- package/{src/bundles/TEMPLATE.ts → lib/bundles/NEST_TEMPLATE.js} +71 -27
- package/lib/bundles/NEST_TEMPLATE.js.map +1 -0
- package/lib/bundles/SDK_TEMPLATE.d.ts +5 -0
- package/lib/bundles/SDK_TEMPLATE.js +61 -0
- package/lib/bundles/SDK_TEMPLATE.js.map +1 -0
- package/lib/bundles/TEMPLATE.d.ts +1 -1
- package/lib/bundles/TEMPLATE.js +23 -23
- package/lib/bundles/TEMPLATE.js.map +1 -1
- package/lib/executable/bundle.js +70 -51
- package/lib/executable/bundle.js.map +1 -1
- package/lib/executable/migrate.js +2 -62
- package/lib/executable/migrate.js.map +1 -1
- package/lib/internal/MigrateCli.d.ts +3 -0
- package/lib/internal/MigrateCli.js +59 -0
- package/lib/internal/MigrateCli.js.map +1 -0
- package/lib/internal/{MigrateArguments.d.ts → MigrateCommander.d.ts} +2 -1
- package/lib/internal/{MigrateArguments.js → MigrateCommander.js} +23 -20
- package/lib/internal/MigrateCommander.js.map +1 -0
- package/lib/programmers/ApiProgrammer.js +47 -2
- package/lib/programmers/ApiProgrammer.js.map +1 -1
- package/package.json +3 -2
- package/src/IMigrateConfig.ts +1 -0
- package/src/MigrateApplication.ts +20 -67
- package/src/bundles/NEST_TEMPLATE.ts +202 -0
- package/src/bundles/SDK_TEMPLATE.ts +57 -0
- package/src/executable/bundle.ts +80 -50
- package/src/executable/migrate.ts +2 -60
- package/src/internal/MigrateCommander.ts +52 -0
- package/src/internal/{MigrateArguments.ts → MigrateInquirer.ts} +12 -7
- package/src/programmers/ApiProgrammer.ts +60 -2
- package/lib/internal/MigrateArguments.js.map +0 -1
package/lib/IMigrateConfig.d.ts
CHANGED
@@ -1,20 +1,8 @@
|
|
1
|
-
import { IMigrateConfig } from "./IMigrateConfig";
|
2
1
|
import { IMigrateFile } from "./structures/IMigrateFile";
|
3
|
-
import { IMigrateProgram } from "./structures/IMigrateProgram";
|
4
2
|
import { ISwagger } from "./structures/ISwagger";
|
5
3
|
export declare class MigrateApplication {
|
6
|
-
readonly config: IMigrateConfig;
|
7
4
|
readonly swagger: ISwagger;
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
analyze(): IMigrateProgram;
|
12
|
-
write(): IMigrateFile[];
|
13
|
-
generate(output: string): Promise<void>;
|
14
|
-
}
|
15
|
-
export declare namespace NestiaMigrateApplication {
|
16
|
-
interface IArchiver {
|
17
|
-
mkdir: (path: string) => void;
|
18
|
-
writeFile: (path: string, content: string) => void;
|
19
|
-
}
|
5
|
+
constructor(swagger: ISwagger);
|
6
|
+
nest(simulate: boolean): IMigrateFile[];
|
7
|
+
sdk(simulate: boolean): IMigrateFile[];
|
20
8
|
}
|
@@ -1,30 +1,19 @@
|
|
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
|
-
};
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
4
|
};
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
6
|
exports.MigrateApplication = void 0;
|
16
|
-
const child_process_1 = __importDefault(require("child_process"));
|
17
|
-
const fs_1 = __importDefault(require("fs"));
|
18
7
|
const typia_1 = __importDefault(require("typia"));
|
19
8
|
const MigrateAnalyzer_1 = require("./analyzers/MigrateAnalyzer");
|
20
|
-
const
|
21
|
-
const
|
9
|
+
const NEST_TEMPLATE_1 = require("./bundles/NEST_TEMPLATE");
|
10
|
+
const SDK_TEMPLATE_1 = require("./bundles/SDK_TEMPLATE");
|
22
11
|
const ApiProgrammer_1 = require("./programmers/ApiProgrammer");
|
23
12
|
const NestProgrammer_1 = require("./programmers/NestProgrammer");
|
24
13
|
class MigrateApplication {
|
25
|
-
constructor(
|
26
|
-
this.
|
27
|
-
|
14
|
+
constructor(swagger) {
|
15
|
+
this.swagger = swagger;
|
16
|
+
(input => {
|
28
17
|
const __is = input => {
|
29
18
|
const $io0 = input => "string" === typeof input.openapi && RegExp(/^3\.0\.[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/).test(input.openapi) && ("object" === typeof input.info && null !== input.info && $io1(input.info)) && (Array.isArray(input.servers) && input.servers.every(elem => "object" === typeof elem && null !== elem && $io4(elem))) && ("object" === typeof input.components && null !== input.components && false === Array.isArray(input.components) && $io5(input.components)) && ("object" === typeof input.paths && null !== input.paths && false === Array.isArray(input.paths) && $io30(input.paths)) && (undefined === input.security || Array.isArray(input.security) && input.security.every(elem => "object" === typeof elem && null !== elem && false === Array.isArray(elem) && $io42(elem)));
|
30
19
|
const $io1 = input => "string" === typeof input.title && (undefined === input.description || "string" === typeof input.description) && (undefined === input.termsOfService || "string" === typeof input.termsOfService && (/\/|:/.test(input.termsOfService) && /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i.test(input.termsOfService))) && (undefined === input.contact || "object" === typeof input.contact && null !== input.contact && false === Array.isArray(input.contact) && $io2(input.contact)) && (undefined === input.license || "object" === typeof input.license && null !== input.license && $io3(input.license)) && "string" === typeof input.version;
|
@@ -1476,54 +1465,24 @@ class MigrateApplication {
|
|
1476
1465
|
})(input, "$input", true);
|
1477
1466
|
return input;
|
1478
1467
|
})(swagger);
|
1479
|
-
this.program = null;
|
1480
|
-
this.files = null;
|
1481
|
-
}
|
1482
|
-
analyze() {
|
1483
|
-
if (this.program === null)
|
1484
|
-
this.program = MigrateAnalyzer_1.MigrateAnalyzer.analyze(this.config)(this.swagger);
|
1485
|
-
return this.program;
|
1486
1468
|
}
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
1491
|
-
|
1492
|
-
|
1493
|
-
|
1494
|
-
|
1495
|
-
|
1496
|
-
|
1469
|
+
nest(simulate) {
|
1470
|
+
const program = MigrateAnalyzer_1.MigrateAnalyzer.analyze({
|
1471
|
+
mode: "nest",
|
1472
|
+
simulate,
|
1473
|
+
})(this.swagger);
|
1474
|
+
return [
|
1475
|
+
...NEST_TEMPLATE_1.NEST_TEMPLATE,
|
1476
|
+
...NestProgrammer_1.NestProgrammer.write(program),
|
1477
|
+
...ApiProgrammer_1.ApiProgrammer.write(program),
|
1478
|
+
];
|
1497
1479
|
}
|
1498
|
-
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
})(output);
|
1505
|
-
try {
|
1506
|
-
child_process_1.default.execSync(`git clone https://github.com/samchon/nestia-template "${output}"`, { stdio: "ignore" });
|
1507
|
-
try {
|
1508
|
-
for (const path of [
|
1509
|
-
"/.git",
|
1510
|
-
"/src/api",
|
1511
|
-
"/src/controllers",
|
1512
|
-
"/src/providers",
|
1513
|
-
"/test/features",
|
1514
|
-
])
|
1515
|
-
fs_1.default.rmSync(`${output}${path}`, {
|
1516
|
-
recursive: true,
|
1517
|
-
force: true,
|
1518
|
-
});
|
1519
|
-
}
|
1520
|
-
catch (_a) { }
|
1521
|
-
}
|
1522
|
-
catch (exp) {
|
1523
|
-
yield archiver(TEMPLATE_1.TEMPLATE);
|
1524
|
-
}
|
1525
|
-
yield archiver(files);
|
1526
|
-
});
|
1480
|
+
sdk(simulate) {
|
1481
|
+
const program = MigrateAnalyzer_1.MigrateAnalyzer.analyze({
|
1482
|
+
mode: "sdk",
|
1483
|
+
simulate,
|
1484
|
+
})(this.swagger);
|
1485
|
+
return [...SDK_TEMPLATE_1.SDK_TEMPLATE, ...ApiProgrammer_1.ApiProgrammer.write(program)];
|
1527
1486
|
}
|
1528
1487
|
}
|
1529
1488
|
exports.MigrateApplication = MigrateApplication;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"MigrateApplication.js","sourceRoot":"","sources":["../src/MigrateApplication.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"MigrateApplication.js","sourceRoot":"","sources":["../src/MigrateApplication.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iEAA8D;AAC9D,2DAAwD;AACxD,yDAAsD;AACtD,+DAA4D;AAC5D,iEAA8D;AAI9D,MAAa,kBAAkB;IAC7B,YAAmC,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;QAClD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAAA,eAAK,CAAC,MAAM;kCAAZ,eAAK,CAAC,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;WAAC,OAAO,EAAE;IACxB,CAAC;IAEM,IAAI,CAAC,QAAiB;QAC3B,MAAM,OAAO,GAAG,iCAAe,CAAC,OAAO,CAAC;YACtC,IAAI,EAAE,MAAM;YACZ,QAAQ;SACT,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjB,OAAO;YACL,GAAG,6BAAa;YAChB,GAAG,+BAAc,CAAC,KAAK,CAAC,OAAO,CAAC;YAChC,GAAG,6BAAa,CAAC,KAAK,CAAC,OAAO,CAAC;SAChC,CAAC;IACJ,CAAC;IAEM,GAAG,CAAC,QAAiB;QAC1B,MAAM,OAAO,GAAG,iCAAe,CAAC,OAAO,CAAC;YACtC,IAAI,EAAE,KAAK;YACX,QAAQ;SACT,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjB,OAAO,CAAC,GAAG,2BAAY,EAAE,GAAG,6BAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5D,CAAC;CACF;AAxBD,gDAwBC"}
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.NEST_TEMPLATE = void 0;
|
4
|
+
exports.NEST_TEMPLATE = [
|
2
5
|
{
|
3
6
|
"location": "",
|
4
7
|
"file": ".env",
|
@@ -10,12 +13,12 @@ export const TEMPLATE = [
|
|
10
13
|
"content": "module.exports = {\r\n root: true,\r\n plugins: [\"@typescript-eslint\", \"deprecation\"],\r\n extends: [\"plugin:@typescript-eslint/recommended\"],\r\n parser: \"@typescript-eslint/parser\",\r\n parserOptions: {\r\n project: [\"tsconfig.json\", \"test/tsconfig.json\"],\r\n },\r\n overrides: [\r\n {\r\n files: [\"src/**/*.ts\", \"test/**/*.ts\"],\r\n rules: {\r\n \"@typescript-eslint/no-explicit-any\": \"off\",\r\n \"@typescript-eslint/no-floating-promises\": \"error\",\r\n \"@typescript-eslint/no-inferrable-types\": \"off\",\r\n \"@typescript-eslint/no-namespace\": \"off\",\r\n \"@typescript-eslint/no-non-null-assertion\": \"off\",\r\n \"@typescript-eslint/no-var-requires\": \"off\",\r\n \"deprecation/deprecation\": \"error\",\r\n },\r\n },\r\n ],\r\n};\r\n"
|
11
14
|
},
|
12
15
|
{
|
13
|
-
"location": "
|
16
|
+
"location": ".github",
|
14
17
|
"file": "dependabot.yml",
|
15
18
|
"content": "version: 2\r\nupdates:\r\n#######################################################\r\n - package-ecosystem: 'npm'\r\n directory: '/'\r\n schedule:\r\n interval: 'daily'\r\n open-pull-requests-limit: 25\r\n allow:\r\n - dependency-name: \"@nestjs/*\"\r\n - dependency-name: \"@nestia/*\"\r\n - dependency-name: \"nestia\"\r\n - dependency-name: \"tstl\"\r\n - dependency-name: \"typia\"\r\n#######################################################\r\n - package-ecosystem: 'npm'\r\n directory: '/packages/api'\r\n schedule:\r\n interval: 'daily'\r\n open-pull-requests-limit: 25\r\n#######################################################"
|
16
19
|
},
|
17
20
|
{
|
18
|
-
"location": "
|
21
|
+
"location": ".github/workflows",
|
19
22
|
"file": "build.yml",
|
20
23
|
"content": "name: build\r\non: [push, pull_request]\r\n\r\njobs:\r\n Ubuntu:\r\n runs-on: ubuntu-latest\r\n steps:\r\n - uses: actions/checkout@v3\r\n - uses: actions/setup-node@v3\r\n \r\n - name: Install Backend-Server\r\n run: npm install\r\n\r\n - name: Build Swagger\r\n run: npm run build:swagger\r\n\r\n - name: Build SDK\r\n run: npm run build:sdk\r\n\r\n - name: Compile Backend-Server\r\n run: npm run build\r\n\r\n - name: Run Test Program\r\n run: npm run test\r\n\r\n - name: Test Webpack\r\n run: npm run webpack && npm run test:webpack\r\n\r\n - name: EsLint\r\n run: npm run eslint\r\n"
|
21
24
|
},
|
@@ -30,12 +33,12 @@ export const TEMPLATE = [
|
|
30
33
|
"content": "dist\r\nbin\r\nnode_modules\r\npackages\r\nsrc/api/functional\r\nsrc/api/utils/NestiaSimulator.ts\r\nREADME.md\r\ntsconfig.json"
|
31
34
|
},
|
32
35
|
{
|
33
|
-
"location": "
|
36
|
+
"location": ".vscode",
|
34
37
|
"file": "launch.json",
|
35
38
|
"content": "{\r\n // Use IntelliSense to learn about possible Node.js debug attributes.\r\n // Hover to view descriptions of existing attributes.\r\n // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387\r\n \"version\": \"0.2.0\",\r\n \"configurations\": [\r\n {\r\n \"type\": \"node\",\r\n \"request\": \"launch\",\r\n \"name\": \"Backend Test\",\r\n \"program\": \"${workspaceRoot}/test/index.ts\",\r\n \"cwd\": \"${workspaceRoot}\",\r\n \"args\": [\r\n // //----\r\n // // Not possible to reset DB in debugging mode\r\n // //\r\n // // Therefore, if you need DB reset, then do it \r\n // // through `npm run reset-for-debugging` command\r\n // //----\r\n // \"--reset\", \"false\",\r\n // \"--mode\", \"local\",\r\n \r\n //----\r\n // You can run specific test functions\r\n //\r\n // If you want to include or exclude multiple words,\r\n // then separate them with space character\r\n //----\r\n // \"--include\", \"some-words-to-include\",\r\n // \"--exclude\", \"some-word another-word\",\r\n ],\r\n \"outFiles\": [\"${workspaceRoot}/bin/**/*.js\"],\r\n }\r\n]\r\n}"
|
36
39
|
},
|
37
40
|
{
|
38
|
-
"location": "
|
41
|
+
"location": ".vscode",
|
39
42
|
"file": "settings.json",
|
40
43
|
"content": "{\r\n \"editor.tabSize\": 2,\r\n \"editor.formatOnSave\": true,\r\n \"[javascript][typescript]\": {\r\n \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\r\n \"editor.codeActionsOnSave\": {\r\n \"source.fixAll.eslint\": \"explicit\"\r\n },\r\n }\r\n}"
|
41
44
|
},
|
@@ -55,27 +58,27 @@ export const TEMPLATE = [
|
|
55
58
|
"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 \"test\": \"node bin/test\",\r\n \"test:webpack\": \"npm run webpack && node bin/test/webpack.js\",\r\n \"------------------------BUILDS------------------------\": \"\",\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 && typia patch\",\r\n \"prettier\": \"prettier src --write && prettier test --write\",\r\n \"------------------------WEBPACK------------------------\": \"\",\r\n \"webpack\": \"rimraf dist && webpack\",\r\n \"webpack:start\": \"cd dist && node dist/server\",\r\n \"------------------------DEPLOYS------------------------\": \"\",\r\n \"package:api\": \"npm run build:swagger && npm run build:api && cd packages/api && npm publish\",\r\n \"start\": \"node lib/executable/server\",\r\n \"start:swagger\": \"ts-node src/executable/swagger.ts\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia-start\"\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-start/issues\"\r\n },\r\n \"homepage\": \"https://github.com/samchon/nestia-start#readme\",\r\n \"devDependencies\": {\r\n \"@nestia/e2e\": \"^0.4.1\",\r\n \"@nestia/sdk\": \"^2.4.5\",\r\n \"@trivago/prettier-plugin-sort-imports\": \"^4.3.0\",\r\n \"@types/cli\": \"^0.11.21\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"@types/inquirer\": \"^8.2.5\",\r\n \"@types/node\": \"^18.11.0\",\r\n \"@types/uuid\": \"^8.3.4\",\r\n \"@typescript-eslint/eslint-plugin\": \"^6.19.1\",\r\n \"@typescript-eslint/parser\": \"^6.19.1\",\r\n \"chalk\": \"^4.1.0\",\r\n \"cli\": \"^1.0.1\",\r\n \"copy-webpack-plugin\": \"^11.0.0\",\r\n \"eslint-plugin-deprecation\": \"^2.0.0\",\r\n \"express\": \"^4.18.2\",\r\n \"nestia\": \"^5.1.2\",\r\n \"prettier\": \"^3.2.4\",\r\n \"prettier-plugin-prisma\": \"^5.0.0\",\r\n \"rimraf\": \"^3.0.2\",\r\n \"source-map-support\": \"^0.5.21\",\r\n \"swagger-ui-express\": \"^5.0.0\",\r\n \"ts-loader\": \"^9.5.1\",\r\n \"ts-node\": \"^10.9.1\",\r\n \"ts-patch\": \"^3.0.2\",\r\n \"typescript\": \"^5.3.2\",\r\n \"typescript-transform-paths\": \"^3.4.6\",\r\n \"webpack\": \"^5.89.0\",\r\n \"webpack-cli\": \"^5.1.4\",\r\n \"write-file-webpack-plugin\": \"^4.5.1\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/core\": \"^2.4.5\",\r\n \"@nestia/fetcher\": \"^2.4.5\",\r\n \"@nestjs/common\": \"^10.3.0\",\r\n \"@nestjs/core\": \"^10.3.0\",\r\n \"@nestjs/platform-fastify\": \"^10.3.0\",\r\n \"commander\": \"10.0.0\",\r\n \"dotenv\": \"^16.3.1\",\r\n \"dotenv-expand\": \"^10.0.0\",\r\n \"inquirer\": \"8.2.5\",\r\n \"serialize-error\": \"^4.1.0\",\r\n \"tstl\": \"^2.5.13\",\r\n \"typia\": \"^5.3.12\",\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}"
|
56
59
|
},
|
57
60
|
{
|
58
|
-
"location": "
|
61
|
+
"location": "packages/api",
|
59
62
|
"file": ".gitignore",
|
60
63
|
"content": "lib/\r\nnode_modules/\r\n\r\nswagger.json"
|
61
64
|
},
|
62
65
|
{
|
63
|
-
"location": "
|
66
|
+
"location": "packages/api",
|
64
67
|
"file": "LICENSE",
|
65
68
|
"content": "MIT License\r\n\r\nCopyright (c) 2021 ORGANIZATION\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\nSOFTWARE."
|
66
69
|
},
|
67
70
|
{
|
68
|
-
"location": "
|
71
|
+
"location": "packages/api",
|
69
72
|
"file": "package.json",
|
70
73
|
"content": "{\r\n \"name\": \"@ORGANIZATION/PROJECT-api\",\r\n \"version\": \"0.1.0\",\r\n \"description\": \"SDK library generated by Nestia\",\r\n \"main\": \"lib/index.js\",\r\n \"typings\": \"lib/index.d.ts\",\r\n \"scripts\": {\r\n \"build\": \"npm run build:sdk && npm run compile\",\r\n \"build:sdk\": \"rimraf ../../src/api/functional && cd ../.. && npx nestia sdk && cd packages/api\",\r\n \"compile\": \"rimraf lib && tsc\",\r\n \"deploy\": \"npm run build && npm publish\",\r\n \"prepare\": \"ts-patch install && typia patch\"\r\n },\r\n \"repository\": {\r\n \"type\": \"git\",\r\n \"url\": \"https://github.com/samchon/nestia\"\r\n },\r\n \"author\": \"Jeongho Nam\",\r\n \"license\": \"MIT\",\r\n \"bugs\": {\r\n \"url\": \"https://github.com/samchon/nestia/issues\"\r\n },\r\n \"homepage\": \"https://nestia.io\",\r\n \"files\": [\r\n \"lib\",\r\n \"swagger.json\",\r\n \"package.json\",\r\n \"README.md\"\r\n ],\r\n \"devDependencies\": {\r\n \"rimraf\": \"^5.0.5\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"ts-patch\": \"^3.1.2\",\r\n \"typescript\": \"^5.3.3\"\r\n },\r\n \"dependencies\": {\r\n \"@nestia/fetcher\": \"^2.4.5\",\r\n \"typia\": \"^5.3.12\"\r\n }\r\n}"
|
71
74
|
},
|
72
75
|
{
|
73
|
-
"location": "
|
76
|
+
"location": "packages/api",
|
74
77
|
"file": "README.md",
|
75
78
|
"content": "# SDK Library\r\nThis is a SDK library generated by [`nestia`](https://nestia.io).\r\n\r\nWith this SDK library, you can easily and safely interact with backend server.\r\n\r\nJust import and call some API functions like gif image below:\r\n\r\n\r\n\r\n> Left is server code, and right is client code utilizing the SDK\r\n\r\n\r\n\r\n\r\n# What [`Nestia`](https://nestia.io) is:\r\n\r\n\r\n[](https://github.com/samchon/nestia/blob/master/LICENSE)\r\n[](https://www.npmjs.com/package/@nestia/core)\r\n[](https://www.npmjs.com/package/nestia)\r\n[](https://github.com/samchon/nestia/actions?query=workflow%3Abuild)\r\n[](https://nestia.io/docs/)\r\n\r\n[Nestia](https://nestia.io) is a set of helper libraries for NestJS, supporting below features:\r\n\r\n - `@nestia/core`: super-fast decorators\r\n - `@nestia/sdk`\r\n - SDK generator for clients\r\n - Swagger generator evolved than ever\r\n - Automatic E2E test functions generator\r\n - `nestia`: just CLI (command line interface) tool\r\n\r\n> **Note**\r\n> \r\n> - **Only one line** required, with pure TypeScript type\r\n> - Runtime validator is **20,000x faster** than `class-validator`\r\n> - JSON serialization is **200x faster** than `class-transformer`\r\n> - SDK is similar with [tRPC](https://trpc.io), but much advanced"
|
76
79
|
},
|
77
80
|
{
|
78
|
-
"location": "
|
81
|
+
"location": "packages/api",
|
79
82
|
"file": "tsconfig.json",
|
80
83
|
"content": "{\r\n \"compilerOptions\": {\r\n /* Visit https://aka.ms/tsconfig to read more about this file */\r\n /* Projects */\r\n // \"incremental\": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */\r\n // \"composite\": true, /* Enable constraints that allow a TypeScript project to be used with project references. */\r\n // \"tsBuildInfoFile\": \"./.tsbuildinfo\", /* Specify the path to .tsbuildinfo incremental compilation file. */\r\n // \"disableSourceOfProjectReferenceRedirect\": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */\r\n // \"disableSolutionSearching\": true, /* Opt a project out of multi-project reference checking when editing. */\r\n // \"disableReferencedProjectLoad\": true, /* Reduce the number of projects loaded automatically by TypeScript. */\r\n /* Language and Environment */\r\n \"target\": \"ES5\", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */\r\n \"lib\": [\r\n \"DOM\",\r\n \"ES2015\"\r\n ], /* Specify a set of bundled library declaration files that describe the target runtime environment. */// \"jsx\": \"preserve\", /* Specify what JSX code is generated. */\r\n // \"experimentalDecorators\": true, /* Enable experimental support for TC39 stage 2 draft decorators. */\r\n // \"emitDecoratorMetadata\": true, /* Emit design-type metadata for decorated declarations in source files. */\r\n // \"jsxFactory\": \"\", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */\r\n // \"jsxFragmentFactory\": \"\", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */\r\n // \"jsxImportSource\": \"\", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */\r\n // \"reactNamespace\": \"\", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */\r\n // \"noLib\": true, /* Disable including any library files, including the default lib.d.ts. */\r\n // \"useDefineForClassFields\": true, /* Emit ECMAScript-standard-compliant class fields. */\r\n // \"moduleDetection\": \"auto\", /* Control what method is used to detect module-format JS files. */\r\n /* Modules */\r\n \"module\": \"commonjs\", /* Specify what module code is generated. */// \"rootDir\": \"./\", /* Specify the root folder within your source files. */\r\n // \"moduleResolution\": \"node\", /* Specify how TypeScript looks up a file from a given module specifier. */\r\n // \"baseUrl\": \"./\", /* Specify the base directory to resolve non-relative module names. */\r\n // \"paths\": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */\r\n // \"rootDirs\": [], /* Allow multiple folders to be treated as one when resolving modules. */\r\n // \"typeRoots\": [], /* Specify multiple folders that act like './node_modules/@types'. */\r\n // \"types\": [], /* Specify type package names to be included without being referenced in a source file. */\r\n // \"allowUmdGlobalAccess\": true, /* Allow accessing UMD globals from modules. */\r\n // \"moduleSuffixes\": [], /* List of file name suffixes to search when resolving a module. */\r\n // \"resolveJsonModule\": true, /* Enable importing .json files. */\r\n // \"noResolve\": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */\r\n /* JavaScript Support */\r\n // \"allowJs\": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */\r\n // \"checkJs\": true, /* Enable error reporting in type-checked JavaScript files. */\r\n // \"maxNodeModuleJsDepth\": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */\r\n /* Emit */\r\n \"declaration\": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */// \"declarationMap\": true, /* Create sourcemaps for d.ts files. */\r\n // \"emitDeclarationOnly\": true, /* Only output d.ts files and not JavaScript files. */\r\n \"sourceMap\": true, /* Create source map files for emitted JavaScript files. */// \"outFile\": \"./\", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */\r\n \"outDir\": \"./lib\", /* Specify an output folder for all emitted files. */// \"removeComments\": true, /* Disable emitting comments. */\r\n // \"noEmit\": true, /* Disable emitting files from a compilation. */\r\n // \"importHelpers\": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */\r\n // \"importsNotUsedAsValues\": \"remove\", /* Specify emit/checking behavior for imports that are only used for types. */\r\n \"downlevelIteration\": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */// \"sourceRoot\": \"\", /* Specify the root path for debuggers to find the reference source code. */\r\n // \"mapRoot\": \"\", /* Specify the location where debugger should locate map files instead of generated locations. */\r\n // \"inlineSourceMap\": true, /* Include sourcemap files inside the emitted JavaScript. */\r\n // \"inlineSources\": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */\r\n // \"emitBOM\": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */\r\n \"newLine\": \"lf\", /* Set the newline character for emitting files. */// \"stripInternal\": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */\r\n // \"noEmitHelpers\": true, /* Disable generating custom helper functions like '__extends' in compiled output. */\r\n // \"noEmitOnError\": true, /* Disable emitting files if any type checking errors are reported. */\r\n // \"preserveConstEnums\": true, /* Disable erasing 'const enum' declarations in generated code. */\r\n // \"declarationDir\": \"./\", /* Specify the output directory for generated declaration files. */\r\n // \"preserveValueImports\": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */\r\n /* Interop Constraints */\r\n // \"isolatedModules\": true, /* Ensure that each file can be safely transpiled without relying on other imports. */\r\n // \"allowSyntheticDefaultImports\": true, /* Allow 'import x from y' when a module doesn't have a default export. */\r\n \"esModuleInterop\": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */// \"preserveSymlinks\": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */\r\n \"forceConsistentCasingInFileNames\": true, /* Ensure that casing is correct in imports. *//* Type Checking */\r\n \"strict\": true, /* Enable all strict type-checking options. */// \"noImplicitAny\": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */\r\n // \"strictNullChecks\": true, /* When type checking, take into account 'null' and 'undefined'. */\r\n // \"strictFunctionTypes\": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */\r\n // \"strictBindCallApply\": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */\r\n // \"strictPropertyInitialization\": true, /* Check for class properties that are declared but not set in the constructor. */\r\n // \"noImplicitThis\": true, /* Enable error reporting when 'this' is given the type 'any'. */\r\n // \"useUnknownInCatchVariables\": true, /* Default catch clause variables as 'unknown' instead of 'any'. */\r\n // \"alwaysStrict\": true, /* Ensure 'use strict' is always emitted. */\r\n // \"noUnusedLocals\": true, /* Enable error reporting when local variables aren't read. */\r\n // \"noUnusedParameters\": true, /* Raise an error when a function parameter isn't read. */\r\n // \"exactOptionalPropertyTypes\": true, /* Interpret optional property types as written, rather than adding 'undefined'. */\r\n // \"noImplicitReturns\": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */\r\n // \"noFallthroughCasesInSwitch\": true, /* Enable error reporting for fallthrough cases in switch statements. */\r\n // \"noUncheckedIndexedAccess\": true, /* Add 'undefined' to a type when accessed using an index. */\r\n // \"noImplicitOverride\": true, /* Ensure overriding members in derived classes are marked with an override modifier. */\r\n // \"noPropertyAccessFromIndexSignature\": true, /* Enforces using indexed accessors for keys declared using an indexed type. */\r\n // \"allowUnusedLabels\": true, /* Disable error reporting for unused labels. */\r\n // \"allowUnreachableCode\": true, /* Disable error reporting for unreachable code. */\r\n /* Completeness */\r\n // \"skipDefaultLibCheck\": true, /* Skip type checking .d.ts files that are included with TypeScript. */\r\n \"skipLibCheck\": true, /* Skip type checking all .d.ts files. */\r\n \"plugins\": [\r\n {\r\n \"transform\": \"typia/lib/transform\"\r\n }\r\n ],\r\n \"strictNullChecks\": true\r\n },\r\n \"include\": [\r\n \"../../src/api\"\r\n ]\r\n}"
|
81
84
|
},
|
@@ -90,62 +93,102 @@ export const TEMPLATE = [
|
|
90
93
|
"content": "# Nestia Template\r\n## Outline\r\n[](https://github.com/samchon/nestia-start/actions?query=workflow%3Abuild)\r\n\r\nA template repository for backend projects using [nestia](https://github.com/samchon/nestia).\r\n\r\nYou can create a new project from this boilerplate by running below command:\r\n\r\n```bash\r\nnpx nestia start <directory>\r\n```\r\n\r\nFor reference, this is a minimal boilerplate project concentrating only on [nestia](https://github.com/samchon/nestia) SDK generation. \r\n\r\nIf you wanna much detailed boilerplate project, visit [`@samchon/backend`](https://github.com/samchon/backend).\r\n\r\n\r\n\r\n\r\n## Directories and Files\r\nThis template project has categorized directories like below.\r\n\r\nAs you can see from the below, all of the Backend source files are placed into the [src](src/) directory. When you build the TypeScript source files, compiled files would be placed into the `lib` directory following the [tsconfig.json](tsconfig.json) configuration. Otherwise you build client [SDK](#32-sdk) library for npm publishing and their compiled files would be placed into the [packages](packages) directory.\r\n\r\n - [packages/api/](packages/api): SDK module built by `npm run build:api`\r\n - [src/](src): Backend source directory\r\n - [src/api/](src/api/): Client SDK that would be published to the `@ORGANIZATION/PROJECT-api`\r\n - [**src/api/functional/**](src/api/functional/): API functions generated by the [`nestia`](https://github.com/samchon/nestia)\r\n - [**src/api/structures/**](src/api/structures/): DTO structures\r\n - [src/controllers/](src/controllers/): Controller classes of the Main Program\r\n - [**test/**](test): Test Automation Program\r\n - [nestia.config.ts](nestia.config.ts): Configuration file of [`nestia`](https://github.com/samchon/nestia)\r\n - [package.json](package.json): NPM configuration\r\n - [tsconfig.json](tsconfig.json): TypeScript configuration for the main program\r\n - [tsconfig.api.json](tsconfig.api.json): TypeScript configuration for the SDK generation\r\n\r\n\r\n\r\n\r\n## NPM Run Commands\r\nList of the run commands defined in the [package.json](package.json) are like below:\r\n\r\n - `build`: Build everything\r\n - `build:api`: Build client SDK libray for the client developers\r\n - `build:main`: Build main program (`src` directory)\r\n - `build:sdk`: Build SDK into main program only\r\n - `build:swagger`: Build Swagger Documents\r\n - `build:test` Build test automation program (`test` directory)\r\n - `dev`: Incremental build for development (test program)\r\n - `eslint` & `eslint:fix` & `prettier`: Prettier and ESLint execution\r\n - `start`: Start local NestJS server\r\n - `test`: Run test automation program\r\n\r\n\r\n\r\n\r\n## Specialization\r\nTransform this template project to be yours.\r\n\r\nWhen you've created a new backend project through this template project, you can specialize it to be suitable for you by changing some words. Replace below words through IDE specific function like `Edit > Replace in Files` (*Ctrl + Shift + H*), who've been supported by the VSCode.\r\n\r\n| Before | After\r\n|-----------------|----------------------------------------\r\n| ORGANIZATION | Your account or corporation name\r\n| PROJECT | Your own project name\r\n| AUTHOR | Author name\r\n| https://github.com/samchon/nestia-start | Your repository URL\r\n\r\n\r\n\r\n\r\n## Test Driven Development\r\nWith [nestia](https://github.com/samchon/nestia) helps to accomplish TDD (Test Driven Development). \r\n\r\nJust define DTOs and API controllers' methods (only declarations) first. After the definitions, and build SDK (Software Development Kit) through [nestia](https://github.com/samchon/nestia) (`npm run build:sdk`). After buildling those SDK, develop test automation program using the SDK, following use-case scenarios in the framework of client side.\r\n\r\nDuring the test automation program development, you can find that which API is mis-designed or which requirement analysis is not exact. Development of the main program must be the last step after such validation process during TDD.\r\n\r\n> Visit the [samchon/backend](https://github.com/samchon/backend), then you may find much detailed story about this TDD.\r\n>\r\n> 1. Definitions\r\n> 2. SDK\r\n> 3. Test Automation Program\r\n> 4. Main Program\r\n\r\n```typescript\r\nimport typia from \"typia\";\r\n\r\nimport api from \"@ORGANIZATION/PROJECT-api/lib/index\";\r\nimport { IBbsArticle } from \"@ORGANIZATION/PROJECT-api/lib/structures/bbs/IBbsArticle\";\r\n\r\nimport { ArrayUtil } from \"../../../../utils/ArrayUtil\";\r\nimport { GaffComparator } from \"../../../internal/GaffComparator\";\r\nimport { RandomGenerator } from \"../../../internal/RandomGenerator\";\r\nimport { validate_index_sort } from \"../../../internal/validate_index_sort\";\r\n\r\nexport async function test_api_bbs_article_index_sort(\r\n connection: api.IConnection,\r\n): Promise<void> {\r\n // GENERATE 100 ARTICLES\r\n const section: string = \"general\";\r\n const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>\r\n api.functional.bbs.articles.store(connection, section, {\r\n writer: RandomGenerator.name(),\r\n title: RandomGenerator.paragraph(),\r\n body: RandomGenerator.content(),\r\n format: \"txt\",\r\n files: [],\r\n password: RandomGenerator.alphabets(8),\r\n }),\r\n );\r\n typia.assertEquals(articles);\r\n\r\n // PREPARE VALIDATOR\r\n const validator = validate_index_sort(\"BbsArticleProvider.index()\")(\r\n (input: IBbsArticle.IRequest) =>\r\n api.functional.bbs.articles.index(connection, section, input),\r\n );\r\n\r\n // DO VALIDATE\r\n const components = [\r\n validator(\"created_at\")(GaffComparator.dates((x) => x.created_at)),\r\n validator(\"updated_at\")(GaffComparator.dates((x) => x.updated_at)),\r\n validator(\"title\")(GaffComparator.strings((x) => x.title)),\r\n validator(\"writer\")(GaffComparator.strings((x) => x.writer)),\r\n validator(\r\n \"writer\",\r\n \"title\",\r\n )(GaffComparator.strings((x) => [x.writer, x.title])),\r\n ];\r\n for (const comp of components) {\r\n await comp(\"+\");\r\n await comp(\"-\");\r\n }\r\n}\r\n```"
|
91
94
|
},
|
92
95
|
{
|
93
|
-
"location": "
|
96
|
+
"location": "src/api",
|
97
|
+
"file": "HttpError.ts",
|
98
|
+
"content": "export { HttpError } from \"@nestia/fetcher\";\r\n"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"location": "src/api",
|
102
|
+
"file": "IConnection.ts",
|
103
|
+
"content": "export type { IConnection } from \"@nestia/fetcher\";\r\n"
|
104
|
+
},
|
105
|
+
{
|
106
|
+
"location": "src/api",
|
107
|
+
"file": "index.ts",
|
108
|
+
"content": "import * as api from \"./module\";\r\n\r\nexport * from \"./module\";\r\nexport default api;\r\n"
|
109
|
+
},
|
110
|
+
{
|
111
|
+
"location": "src/api",
|
112
|
+
"file": "module.ts",
|
113
|
+
"content": "export type * from \"./IConnection\";\r\nexport * from \"./HttpError\";\r\n\r\nexport * as functional from \"./functional\";\r\n"
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"location": "src/api",
|
117
|
+
"file": "Primitive.ts",
|
118
|
+
"content": "export type { Primitive } from \"@nestia/fetcher\";\r\n"
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"location": "src/api/structures/bbs",
|
122
|
+
"file": "IBbsArticle.ts",
|
123
|
+
"content": "import { tags } from \"typia\";\r\n\r\nimport { IAttachmentFile } from \"../common/IAttachmentFile\";\r\nimport { IPage } from \"../common/IPage\";\r\n\r\n/**\r\n * BBS article.\r\n */\r\nexport interface IBbsArticle {\r\n /**\r\n * Primary Key.\r\n */\r\n id: string & tags.Format<\"uuid\">;\r\n\r\n /**\r\n * Section code.\r\n */\r\n section: string;\r\n\r\n /**\r\n * Name of nickname of writer.\r\n */\r\n writer: string;\r\n\r\n /**\r\n * List of snapshot contents.\r\n *\r\n * Whenever updating an article, its contents would be accumulated.\r\n */\r\n snapshots: IBbsArticle.ISnapshot[];\r\n\r\n /**\r\n * Creation time of the article.\r\n */\r\n created_at: string & tags.Format<\"date-time\">;\r\n}\r\n\r\nexport namespace IBbsArticle {\r\n /**\r\n * Page request info with some options.\r\n */\r\n export interface IRequest extends IPage.IRequest {\r\n /**\r\n * Searching options.\r\n */\r\n search?: IRequest.ISearch;\r\n\r\n /**\r\n * Sorting options.\r\n *\r\n * The plus sign means ASC and minus sign means DESC.\r\n */\r\n sort?: IPage.Sort<IRequest.SortableColumns>;\r\n }\r\n export namespace IRequest {\r\n /**\r\n * Searching options.\r\n */\r\n export interface ISearch {\r\n writer?: string;\r\n title?: string;\r\n body?: string;\r\n }\r\n\r\n /**\r\n * List of sortable columns.\r\n */\r\n export type SortableColumns =\r\n | \"writer\"\r\n | \"title\"\r\n | \"created_at\"\r\n | \"updated_at\";\r\n }\r\n\r\n /**\r\n * Summarized info.\r\n */\r\n export interface ISummary {\r\n id: string;\r\n writer: string;\r\n title: string;\r\n created_at: string;\r\n updated_at: string;\r\n }\r\n\r\n /**\r\n * Content info.\r\n */\r\n export interface ISnapshot extends Omit<IUpdate, \"password\"> {\r\n /**\r\n * Primary key of individual content.\r\n */\r\n id: string & tags.Format<\"uuid\">;\r\n\r\n /**\r\n * Creation time of this content.\r\n */\r\n created_at: string & tags.Format<\"date-time\">;\r\n }\r\n\r\n /**\r\n * Store info.\r\n */\r\n export interface ICreate extends IUpdate {\r\n /**\r\n * Name or nickname of the writer.\r\n */\r\n writer: string;\r\n }\r\n\r\n /**\r\n * Update info.\r\n */\r\n export interface IUpdate {\r\n /**\r\n * Title of the article.\r\n */\r\n title: string;\r\n\r\n /**\r\n * Content body.\r\n */\r\n body: string;\r\n\r\n /**\r\n * Format of the content body.\r\n */\r\n format: \"md\" | \"html\" | \"txt\";\r\n\r\n /**\r\n * List of files (to be) attached.\r\n */\r\n files: IAttachmentFile[];\r\n\r\n /**\r\n * Password of the article.\r\n */\r\n password: string;\r\n }\r\n}\r\n"
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"location": "src/api/structures/common",
|
127
|
+
"file": "IAttachmentFile.ts",
|
128
|
+
"content": "import { tags } from \"typia\";\r\n\r\nexport interface IAttachmentFile {\r\n name: null | (string & tags.MinLength<1> & tags.MaxLength<255>);\r\n extension: null | (string & tags.MinLength<1> & tags.MaxLength<8>);\r\n url: string & tags.Format<\"url\">;\r\n}\r\n"
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"location": "src/api/structures/common",
|
132
|
+
"file": "IPage.ts",
|
133
|
+
"content": "import { tags } from \"typia\";\r\n\r\n/**\r\n * A page.\r\n *\r\n * Collection of records with pagination indformation.\r\n *\r\n * @author Samchon\r\n */\r\nexport interface IPage<T extends object> {\r\n /**\r\n * Page information.\r\n */\r\n pagination: IPage.IPagination;\r\n\r\n /**\r\n * List of records.\r\n */\r\n data: T[];\r\n}\r\nexport namespace IPage {\r\n /**\r\n * Page information.\r\n */\r\n export interface IPagination {\r\n /**\r\n * Current page number.\r\n */\r\n current: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Limitation of records per a page.\r\n *\r\n * @default 100\r\n */\r\n limit: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Count of total records in database.\r\n */\r\n records: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Number of total pages.\r\n *\r\n * Equal to {@link records} / {@link limit} with ceiling.\r\n */\r\n pages: number & tags.Type<\"uint32\">;\r\n }\r\n\r\n /**\r\n * Page request data\r\n */\r\n export interface IRequest {\r\n /**\r\n * Page number.\r\n */\r\n page?: number & tags.Type<\"uint32\">;\r\n\r\n /**\r\n * Limitation of records per a page.\r\n */\r\n limit?: number & tags.Type<\"uint32\">;\r\n }\r\n\r\n /**\r\n * Sorting column specialization.\r\n *\r\n * The plus means ascending order and the minus means descending order.\r\n */\r\n export type Sort<Literal extends string> = Array<\r\n `-${Literal}` | `+${Literal}`\r\n >;\r\n}\r\n"
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"location": "src/api/utils",
|
137
|
+
"file": "NestiaSimulator.ts",
|
138
|
+
"content": "import { HttpError } from \"@nestia/fetcher\";\r\n\r\nimport typia from \"typia\";\r\n\r\nexport namespace NestiaSimulator {\r\n export interface IProps {\r\n host: string;\r\n path: string;\r\n method: \"GET\" | \"POST\" | \"PATCH\" | \"PUT\" | \"DELETE\";\r\n contentType: string;\r\n }\r\n\r\n export const assert = (props: IProps) => {\r\n return {\r\n param: param(props),\r\n query: query(props),\r\n body: body(props),\r\n };\r\n };\r\n const param =\r\n (props: IProps) =>\r\n (name: string) =>\r\n <T>(task: () => T): void => {\r\n validate(\r\n (exp) => `URL parameter \"${name}\" is not ${exp.expected} type.`,\r\n )(props)(task);\r\n };\r\n\r\n const query =\r\n (props: IProps) =>\r\n <T>(task: () => T): void =>\r\n validate(\r\n () =>\r\n \"Request query parameters are not following the promised type.\",\r\n )(props)(task);\r\n\r\n const body =\r\n (props: IProps) =>\r\n <T>(task: () => T): void =>\r\n validate(() => \"Request body is not following the promised type.\")(\r\n props,\r\n )(task);\r\n\r\n const validate =\r\n (message: (exp: typia.TypeGuardError) => string, path?: string) =>\r\n (props: IProps) =>\r\n <T>(task: () => T): void => {\r\n try {\r\n task();\r\n } catch (exp) {\r\n if (typia.is<typia.TypeGuardError>(exp))\r\n throw new HttpError(\r\n props.method,\r\n props.host + props.path,\r\n 400,\r\n {\r\n \"Content-Type\": props.contentType,\r\n },\r\n JSON.stringify({\r\n method: exp.method,\r\n path: path ?? exp.path,\r\n expected: exp.expected,\r\n value: exp.value,\r\n message: message(exp),\r\n }),\r\n );\r\n throw exp;\r\n }\r\n };\r\n}\r\n"
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"location": "src/executable",
|
94
142
|
"file": "server.ts",
|
95
143
|
"content": "import fs from \"fs\";\r\nimport { randint } from \"tstl/algorithm/random\";\r\nimport { Singleton } from \"tstl/thread/Singleton\";\r\n\r\nimport { MyBackend } from \"../MyBackend\";\r\nimport { MyConfiguration } from \"../MyConfiguration\";\r\nimport { ErrorUtil } from \"../utils/ErrorUtil\";\r\n\r\nconst EXTENSION = __filename.substring(__filename.length - 2);\r\nif (EXTENSION === \"js\") require(\"source-map-support/register\");\r\n\r\nconst directory = new Singleton(async () => {\r\n await mkdir(`${MyConfiguration.ROOT}/assets`);\r\n await mkdir(`${MyConfiguration.ROOT}/assets/logs`);\r\n await mkdir(`${MyConfiguration.ROOT}/assets/logs/errors`);\r\n});\r\n\r\nfunction cipher(val: number): string {\r\n if (val < 10) return \"0\" + val;\r\n else return String(val);\r\n}\r\n\r\nasync function mkdir(path: string): Promise<void> {\r\n try {\r\n await fs.promises.mkdir(path);\r\n } catch {}\r\n}\r\n\r\nasync function handle_error(exp: any): Promise<void> {\r\n try {\r\n const date: Date = new Date();\r\n const fileName: string = `${date.getFullYear()}${cipher(\r\n date.getMonth() + 1,\r\n )}${cipher(date.getDate())}${cipher(date.getHours())}${cipher(\r\n date.getMinutes(),\r\n )}${cipher(date.getSeconds())}.${randint(0, Number.MAX_SAFE_INTEGER)}`;\r\n const content: string = JSON.stringify(ErrorUtil.toJSON(exp), null, 4);\r\n\r\n await directory.get();\r\n await fs.promises.writeFile(\r\n `${MyConfiguration.ROOT}/assets/logs/errors/${fileName}.log`,\r\n content,\r\n \"utf8\",\r\n );\r\n } catch {}\r\n}\r\n\r\nasync function main(): Promise<void> {\r\n // BACKEND SEVER\r\n const backend: MyBackend = new MyBackend();\r\n await backend.open();\r\n\r\n // UNEXPECTED ERRORS\r\n global.process.on(\"uncaughtException\", handle_error);\r\n global.process.on(\"unhandledRejection\", handle_error);\r\n}\r\nmain().catch((exp) => {\r\n console.log(exp);\r\n process.exit(-1);\r\n});\r\n"
|
96
144
|
},
|
97
145
|
{
|
98
|
-
"location": "
|
146
|
+
"location": "src/executable",
|
99
147
|
"file": "swagger.ts",
|
100
148
|
"content": "import cp from \"child_process\";\r\nimport express from \"express\";\r\n\r\nconst execute = (command: string): void => {\r\n console.log(`\\n$ ${command}\\n`);\r\n cp.execSync(command, { stdio: \"inherit\" });\r\n};\r\n\r\nconst main = async (): Promise<void> => {\r\n if (!process.argv.some((str) => str === \"--skipBuild\"))\r\n execute(\"npm run build:swagger\");\r\n\r\n const docs = await import(\"../../packages/api/swagger.json\" as any);\r\n\r\n const app = express();\r\n const swaggerUi = require(\"swagger-ui-express\");\r\n app.use(\"/api-docs\", swaggerUi.serve, swaggerUi.setup(docs));\r\n app.listen(37810);\r\n\r\n console.log(\"\\n\");\r\n console.log(\"-----------------------------------------------------------\");\r\n console.log(\"\\n Swagger UI Address: http://127.0.0.1:37810/api-docs \\n\");\r\n console.log(\"-----------------------------------------------------------\");\r\n};\r\nmain().catch((exp) => {\r\n console.log(exp);\r\n process.exit(-1);\r\n});\r\n"
|
101
149
|
},
|
102
150
|
{
|
103
|
-
"location": "
|
151
|
+
"location": "src",
|
104
152
|
"file": "MyBackend.ts",
|
105
153
|
"content": "import { NestFactory } from \"@nestjs/core\";\r\nimport {\r\n FastifyAdapter,\r\n NestFastifyApplication,\r\n} from \"@nestjs/platform-fastify\";\r\n\r\nimport { MyConfiguration } from \"./MyConfiguration\";\r\nimport { MyModule } from \"./MyModule\";\r\n\r\nexport class MyBackend {\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 MyModule,\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(MyConfiguration.API_PORT(), \"0.0.0.0\");\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"
|
106
154
|
},
|
107
155
|
{
|
108
|
-
"location": "
|
156
|
+
"location": "src",
|
109
157
|
"file": "MyConfiguration.ts",
|
110
158
|
"content": "import fs from \"fs\";\r\nimport path from \"path\";\r\n\r\nimport { MyGlobal } from \"./MyGlobal\";\r\n\r\nexport namespace MyConfiguration {\r\n export const API_PORT = () => Number(MyGlobal.env.PROJECT_API_PORT);\r\n\r\n export const ROOT = (() => {\r\n const splitted: string[] = __dirname.split(path.sep);\r\n return splitted.at(-1) === \"src\" && splitted.at(-2) === \"bin\"\r\n ? path.resolve(__dirname + \"/../..\")\r\n : fs.existsSync(__dirname + \"/.env\")\r\n ? __dirname\r\n : path.resolve(__dirname + \"/..\");\r\n })();\r\n}\r\n"
|
111
159
|
},
|
112
160
|
{
|
113
|
-
"location": "
|
161
|
+
"location": "src",
|
114
162
|
"file": "MyGlobal.ts",
|
115
163
|
"content": "import dotenv from \"dotenv\";\r\nimport dotenvExpand from \"dotenv-expand\";\r\nimport { Singleton } from \"tstl\";\r\nimport typia from \"typia\";\r\n\r\n/* eslint-disable */\r\nexport class MyGlobal {\r\n public static testing: boolean = false;\r\n public static get env(): MyGlobal.IEnvironments {\r\n return environments.get();\r\n }\r\n}\r\nexport namespace MyGlobal {\r\n export interface IEnvironments {\r\n PROJECT_API_PORT: `${number}`;\r\n }\r\n}\r\n\r\nconst environments = new Singleton(() => {\r\n const env = dotenv.config();\r\n dotenvExpand.expand(env);\r\n return typia.assert<MyGlobal.IEnvironments>(process.env);\r\n});\r\n"
|
116
164
|
},
|
117
165
|
{
|
118
|
-
"location": "/
|
119
|
-
"file": "MyModule.ts",
|
120
|
-
"content": "import { Module } from \"@nestjs/common\";\r\n\r\nimport { BbsArticleModule } from \"./controllers/bbs/BbsArticleModule\";\r\n\r\n@Module({\r\n imports: [BbsArticleModule],\r\n})\r\nexport class MyModule {}\r\n"
|
121
|
-
},
|
122
|
-
{
|
123
|
-
"location": "/src/utils",
|
166
|
+
"location": "src/utils",
|
124
167
|
"file": "ErrorUtil.ts",
|
125
168
|
"content": "import fs from \"fs\";\r\nimport { randint } from \"tstl/algorithm/random\";\r\nimport { Singleton } from \"tstl/thread/Singleton\";\r\n\r\nimport { MyConfiguration } from \"../MyConfiguration\";\r\n\r\nimport serializeError = require(\"serialize-error\");\r\n\r\nexport namespace ErrorUtil {\r\n export const toJSON = (err: any): object =>\r\n err instanceof Object && err.toJSON instanceof Function\r\n ? err.toJSON()\r\n : serializeError(err);\r\n\r\n export const log =\r\n (prefix: string) =>\r\n async (error: string | object | Error): Promise<void> => {\r\n try {\r\n if (error instanceof Error) error = toJSON(error);\r\n\r\n const date: Date = new Date();\r\n const fileName: string = `${date.getFullYear()}${cipher(\r\n date.getMonth() + 1,\r\n )}${cipher(date.getDate())}${cipher(date.getHours())}${cipher(\r\n date.getMinutes(),\r\n )}${cipher(date.getSeconds())}.${randint(0, Number.MAX_SAFE_INTEGER)}`;\r\n const content: string = JSON.stringify(error, null, 4);\r\n\r\n await directory.get();\r\n await fs.promises.writeFile(\r\n `${MyConfiguration.ROOT}/assets/logs/errors/${prefix}_${fileName}.log`,\r\n content,\r\n \"utf8\",\r\n );\r\n } catch {}\r\n };\r\n}\r\n\r\nconst cipher = (val: number): string => String(val).padStart(2, \"0\");\r\nconst directory = new Singleton(async () => {\r\n await mkdir(`${MyConfiguration.ROOT}/assets/logs`);\r\n await mkdir(`${MyConfiguration.ROOT}/assets/logs/errors`);\r\n});\r\nasync function mkdir(path: string): Promise<void> {\r\n try {\r\n await fs.promises.mkdir(path);\r\n } catch {}\r\n}\r\n"
|
126
169
|
},
|
127
170
|
{
|
128
|
-
"location": "
|
171
|
+
"location": "src/utils",
|
129
172
|
"file": "MapUtil.ts",
|
130
173
|
"content": "export namespace MapUtil {\r\n export function take<Key, T>(\r\n dict: Map<Key, T>,\r\n key: Key,\r\n generator: () => T,\r\n ): T {\r\n const oldbie: T | undefined = dict.get(key);\r\n if (oldbie) return oldbie;\r\n\r\n const value: T = generator();\r\n dict.set(key, value);\r\n return value;\r\n }\r\n}\r\n"
|
131
174
|
},
|
132
175
|
{
|
133
|
-
"location": "
|
176
|
+
"location": "test/helpers",
|
134
177
|
"file": "ArgumentParser.ts",
|
135
178
|
"content": "import commander from \"commander\";\r\nimport * as inquirer from \"inquirer\";\r\n\r\nexport namespace ArgumentParser {\r\n export type Inquiry<T> = (\r\n command: commander.Command,\r\n prompt: (opt?: inquirer.StreamOptions) => inquirer.PromptModule,\r\n action: (closure: (options: Partial<T>) => Promise<T>) => Promise<T>,\r\n ) => Promise<T>;\r\n\r\n export interface Prompt {\r\n select: (\r\n name: string,\r\n ) => (\r\n message: string,\r\n ) => <Choice extends string>(choices: Choice[]) => Promise<Choice>;\r\n boolean: (name: string) => (message: string) => Promise<boolean>;\r\n }\r\n\r\n export const parse = async <T>(\r\n inquiry: (\r\n command: commander.Command,\r\n prompt: Prompt,\r\n action: (closure: (options: Partial<T>) => Promise<T>) => Promise<T>,\r\n ) => Promise<T>,\r\n ): Promise<T> => {\r\n // TAKE OPTIONS\r\n const action = (closure: (options: Partial<T>) => Promise<T>) =>\r\n new Promise<T>((resolve, reject) => {\r\n commander.program.action(async (options) => {\r\n try {\r\n resolve(await closure(options));\r\n } catch (exp) {\r\n reject(exp);\r\n }\r\n });\r\n commander.program.parseAsync().catch(reject);\r\n });\r\n\r\n const select =\r\n (name: string) =>\r\n (message: string) =>\r\n async <Choice extends string>(choices: Choice[]): Promise<Choice> =>\r\n (\r\n await inquirer.createPromptModule()({\r\n type: \"list\",\r\n name,\r\n message,\r\n choices,\r\n })\r\n )[name];\r\n const boolean = (name: string) => async (message: string) =>\r\n (\r\n await inquirer.createPromptModule()({\r\n type: \"confirm\",\r\n name,\r\n message,\r\n })\r\n )[name] as boolean;\r\n\r\n const output: T | Error = await (async () => {\r\n try {\r\n return await inquiry(commander.program, { select, boolean }, action);\r\n } catch (error) {\r\n return error as Error;\r\n }\r\n })();\r\n\r\n // RETURNS\r\n if (output instanceof Error) throw output;\r\n return output;\r\n };\r\n}\r\n"
|
136
179
|
},
|
137
180
|
{
|
138
|
-
"location": "
|
181
|
+
"location": "test",
|
139
182
|
"file": "index.ts",
|
140
183
|
"content": "import { DynamicExecutor } from \"@nestia/e2e\";\r\n\r\nimport api from \"@ORGANIZATION/PROJECT-api\";\r\n\r\nimport { MyBackend } from \"../src/MyBackend\";\r\nimport { MyConfiguration } from \"../src/MyConfiguration\";\r\nimport { MyGlobal } from \"../src/MyGlobal\";\r\nimport { ArgumentParser } from \"./helpers/ArgumentParser\";\r\n\r\ninterface IOptions {\r\n include?: string[];\r\n exclude?: string[];\r\n}\r\n\r\nconst getOptions = () =>\r\n ArgumentParser.parse<IOptions>(async (command, prompt, action) => {\r\n // command.option(\"--mode <string>\", \"target mode\");\r\n // command.option(\"--reset <true|false>\", \"reset local DB or not\");\r\n command.option(\"--include <string...>\", \"include feature files\");\r\n command.option(\"--exclude <string...>\", \"exclude feature files\");\r\n\r\n prompt;\r\n\r\n return action(async (options) => {\r\n // if (typeof options.reset === \"string\")\r\n // options.reset = options.reset === \"true\";\r\n // options.mode ??= await prompt.select(\"mode\")(\"Select mode\")([\r\n // \"LOCAL\",\r\n // \"DEV\",\r\n // \"REAL\",\r\n // ]);\r\n // options.reset ??= await prompt.boolean(\"reset\")(\"Reset local DB\");\r\n return options as IOptions;\r\n });\r\n });\r\n\r\nasync function main(): Promise<void> {\r\n const options: IOptions = await getOptions();\r\n MyGlobal.testing = true;\r\n\r\n // BACKEND SERVER\r\n const backend: MyBackend = new MyBackend();\r\n await backend.open();\r\n\r\n //----\r\n // CLINET CONNECTOR\r\n //----\r\n // DO TEST\r\n const connection: api.IConnection = {\r\n host: `http://127.0.0.1:${MyConfiguration.API_PORT()}`,\r\n };\r\n const report: DynamicExecutor.IReport = await DynamicExecutor.validate({\r\n prefix: \"test\",\r\n parameters: () => [\r\n {\r\n host: connection.host,\r\n encryption: connection.encryption,\r\n },\r\n ],\r\n filter: (func) =>\r\n (!options.include?.length ||\r\n (options.include ?? []).some((str) => func.includes(str))) &&\r\n (!options.exclude?.length ||\r\n (options.exclude ?? []).every((str) => !func.includes(str))),\r\n })(__dirname + \"/features\");\r\n\r\n await backend.close();\r\n\r\n const failures: DynamicExecutor.IReport.IExecution[] =\r\n report.executions.filter((exec) => exec.error !== null);\r\n if (failures.length === 0) {\r\n console.log(\"Success\");\r\n console.log(\"Elapsed time\", report.time.toLocaleString(), `ms`);\r\n } else {\r\n for (const f of failures) console.log(f.error);\r\n process.exit(-1);\r\n }\r\n\r\n console.log(\r\n [\r\n `All: #${report.executions.length}`,\r\n `Success: #${report.executions.length - failures.length}`,\r\n `Failed: #${failures.length}`,\r\n ].join(\"\\n\"),\r\n );\r\n}\r\nmain().catch((exp) => {\r\n console.log(exp);\r\n process.exit(-1);\r\n});\r\n"
|
141
184
|
},
|
142
185
|
{
|
143
|
-
"location": "
|
186
|
+
"location": "test",
|
144
187
|
"file": "tsconfig.json",
|
145
188
|
"content": "{\r\n \"extends\": \"../tsconfig.json\",\r\n \"compilerOptions\": {\r\n \"outDir\": \"../bin\",\r\n },\r\n \"include\": [\".\", \"../src\"]\r\n}"
|
146
189
|
},
|
147
190
|
{
|
148
|
-
"location": "
|
191
|
+
"location": "test",
|
149
192
|
"file": "webpack.ts",
|
150
193
|
"content": "import { DynamicExecutor } from \"@nestia/e2e\";\r\nimport cp from \"child_process\";\r\nimport { sleep_for } from \"tstl\";\r\n\r\nimport { MyConfiguration } from \"../src/MyConfiguration\";\r\nimport api from \"../src/api\";\r\n\r\nconst main = async (): Promise<void> => {\r\n // OPEN BUNDLED SERVER\r\n const backend = cp.fork(`${MyConfiguration.ROOT}/dist/server.js`, {\r\n cwd: `${MyConfiguration.ROOT}/dist`,\r\n });\r\n await sleep_for(2_500);\r\n\r\n // DO TEST\r\n const connection: api.IConnection = {\r\n host: `http://127.0.0.1:${MyConfiguration.API_PORT()}`,\r\n };\r\n const report: DynamicExecutor.IReport = await DynamicExecutor.validate({\r\n prefix: \"test\",\r\n parameters: () => [\r\n {\r\n host: connection.host,\r\n encryption: connection.encryption,\r\n },\r\n ],\r\n })(__dirname + \"/features\");\r\n\r\n backend.kill();\r\n\r\n const failures: DynamicExecutor.IReport.IExecution[] =\r\n report.executions.filter((exec) => exec.error !== null);\r\n if (failures.length === 0) {\r\n console.log(\"Success\");\r\n console.log(\"Elapsed time\", report.time.toLocaleString(), `ms`);\r\n } else {\r\n for (const f of failures) console.log(f.error);\r\n process.exit(-1);\r\n }\r\n};\r\nmain().catch((exp) => {\r\n console.log(exp);\r\n process.exit(-1);\r\n});\r\n"
|
151
194
|
},
|
@@ -159,4 +202,5 @@ export const TEMPLATE = [
|
|
159
202
|
"file": "webpack.config.js",
|
160
203
|
"content": "const path = require(\"path\");\r\n\r\nconst CopyWebpackPlugin = require(\"copy-webpack-plugin\");\r\nconst WriteFilePlugin = require(\"write-file-webpack-plugin\");\r\nconst { IgnorePlugin } = require(\"webpack\");\r\n\r\nconst lazyImports = [\r\n \"@fastify/static\",\r\n \"@fastify/view\",\r\n \"@nestjs/microservices\",\r\n \"@nestjs/websockets\",\r\n \"class-transformer\",\r\n \"class-validator\",\r\n];\r\n\r\n// @reference https://tech-blog.s-yoshiki.com/entry/297\r\nmodule.exports = {\r\n // CUSTOMIZE HERE\r\n entry: {\r\n server: \"./src/executable/server.ts\",\r\n },\r\n output: {\r\n path: path.join(__dirname, \"dist\"),\r\n filename: \"[name].js\",\r\n },\r\n optimization: {\r\n minimize: true,\r\n },\r\n\r\n // JUST KEEP THEM\r\n mode: \"production\",\r\n target: \"node\",\r\n module: {\r\n rules: [\r\n {\r\n test: /\\.ts$/,\r\n exclude: /node_modules/,\r\n loader: \"ts-loader\",\r\n },\r\n ],\r\n },\r\n resolve: {\r\n extensions: [\".tsx\", \".ts\", \".js\"],\r\n },\r\n plugins: [\r\n new CopyWebpackPlugin({\r\n patterns: [\r\n {\r\n from: \".env\",\r\n to: \"[name][ext]\",\r\n },\r\n // {\r\n // from: \"./node_modules/.prisma/client/*.node\",\r\n // to: () => Promise.resolve(\"[path][name][ext]\"),\r\n // globOptions: {\r\n // dot: true,\r\n // },\r\n // },\r\n ],\r\n }),\r\n new WriteFilePlugin(),\r\n new IgnorePlugin({\r\n checkResource: (resource) => {\r\n if (lazyImports.some((modulo) => resource.startsWith(modulo))) {\r\n try {\r\n require.resolve(resource);\r\n } catch (err) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n },\r\n }),\r\n ],\r\n};\r\n"
|
161
204
|
}
|
162
|
-
]
|
205
|
+
];
|
206
|
+
//# sourceMappingURL=NEST_TEMPLATE.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"NEST_TEMPLATE.js","sourceRoot":"","sources":["../../src/bundles/NEST_TEMPLATE.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IAC3B;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,MAAM;QACd,SAAS,EAAE,+CAA+C;KAC3D;IACD;QACE,UAAU,EAAE,EAAE;QACd,MAAM,EAAE,eAAe;QACvB,SAAS,EAAE,m1BAAm1B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