nestia 3.1.1 → 3.1.2
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/README.md +133 -17
- package/lib/executable/internal/NestiaStarter.js +10 -26
- package/lib/executable/internal/NestiaStarter.js.map +1 -1
- package/package.json +2 -2
- package/template/.eslintrc.cjs +0 -22
- package/template/.github/workflows/build.yml +0 -18
- package/template/.prettierignore +0 -6
- package/template/.vscode/launch.json +0 -19
- package/template/.vscode/settings.json +0 -10
- package/template/LICENSE +0 -21
- package/template/README.md +0 -131
- package/template/bundle/gitignore +0 -6
- package/template/bundle/npmignore +0 -6
- package/template/nestia.config.ts +0 -12
- package/template/package.json +0 -62
- package/template/packages/api/LICENSE +0 -21
- package/template/packages/api/README.md +0 -66
- package/template/packages/api/package.json +0 -21
- package/template/prettier.config.js +0 -18
- package/template/src/Backend.ts +0 -65
- package/template/src/Configuration.ts +0 -11
- package/template/src/api/HttpError.ts +0 -1
- package/template/src/api/IConnection.ts +0 -1
- package/template/src/api/Primitive.ts +0 -1
- package/template/src/api/__internal/AesPkcs5.ts +0 -1
- package/template/src/api/__internal/Fetcher.ts +0 -1
- package/template/src/api/functional/bbs/articles/index.ts +0 -166
- package/template/src/api/functional/bbs/index.ts +0 -7
- package/template/src/api/functional/index.ts +0 -7
- package/template/src/api/index.ts +0 -4
- package/template/src/api/module.ts +0 -5
- package/template/src/api/structures/bbs/IBbsArticle.ts +0 -142
- package/template/src/api/structures/common/IAttachmentFile.ts +0 -5
- package/template/src/api/structures/common/IPage.ts +0 -75
- package/template/src/controllers/BbsArticlesController.ts +0 -46
- package/template/src/providers/bbs/BbsArticleProvider.ts +0 -217
- package/template/src/test/features/api/bbs/test_api_bbs_article_at.ts +0 -52
- package/template/src/test/features/api/bbs/test_api_bbs_article_index_search.ts +0 -82
- package/template/src/test/features/api/bbs/test_api_bbs_article_index_sort.ts +0 -49
- package/template/src/test/features/api/bbs/test_api_bbs_article_store.ts +0 -44
- package/template/src/test/features/api/bbs/test_api_bbs_article_update.ts +0 -66
- package/template/src/test/index.ts +0 -45
- package/template/src/test/internal/DynamicImportIterator.ts +0 -119
- package/template/src/test/internal/GaffComparator.ts +0 -48
- package/template/src/test/internal/IPointer.ts +0 -3
- package/template/src/test/internal/RandomGenerator.ts +0 -72
- package/template/src/test/internal/StopWatch.ts +0 -16
- package/template/src/test/internal/exception_must_be_thrown.ts +0 -11
- package/template/src/test/internal/validate_index.ts +0 -29
- package/template/src/test/internal/validate_index_sort.ts +0 -39
- package/template/src/utils/ArrayUtil.ts +0 -86
- package/template/src/utils/MapUtil.ts +0 -14
- package/template/tsconfig.api.json +0 -15
- package/template/tsconfig.json +0 -118
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Intersection type | ✔ | ✔ | ▲
|
|
|
26
26
|
Conditional type | ✔ | ▲ | ❌
|
|
27
27
|
Auto completion | ✔ | ❌ | ❌
|
|
28
28
|
Type hints | ✔ | ❌ | ❌
|
|
29
|
-
|
|
29
|
+
5x faster `JSON.stringify()` | ✔ | ❌ | ❌
|
|
30
30
|
Ensure type safety | ✅ | ❌ | ❌
|
|
31
31
|
|
|
32
32
|
```typescript
|
|
@@ -51,6 +51,7 @@ export async function trace_sale_question_and_comment
|
|
|
51
51
|
const sale: ISale = await api.functional.shoppings.sales.at
|
|
52
52
|
(
|
|
53
53
|
connection,
|
|
54
|
+
"general",
|
|
54
55
|
index.data[0].id
|
|
55
56
|
);
|
|
56
57
|
console.log("sale", sale);
|
|
@@ -75,21 +76,31 @@ export async function trace_sale_question_and_comment
|
|
|
75
76
|
|
|
76
77
|
|
|
77
78
|
## Setup
|
|
78
|
-
###
|
|
79
|
+
### Boilerplate Project
|
|
79
80
|
```bash
|
|
80
81
|
npx nestia start <directory>
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
Just run the
|
|
84
|
+
Just run the uppder command, then boilerplate project using `nestia` would be installed.
|
|
85
|
+
|
|
86
|
+
When the installation has been completed, you can start NestJS backend development directly. and you also can generate SDK library or Swagger documents by running below command. You can get more information by reading [README](https://github.com/samchon/nestia-template) content of the boilderplate project.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
cd <directory>
|
|
90
|
+
npm run build:sdk
|
|
91
|
+
npm run build:swagger
|
|
92
|
+
```
|
|
84
93
|
|
|
85
|
-
|
|
94
|
+
However, supported range of the boilerplate project is limited. It guides from "setting up nestia configuration" to "how to accomplish TDD through SDK", but nothing more. If you want more guidance like
|
|
95
|
+
configuring DB or preparing non-distruptive update system, visit [samchon/backend](https://github.com/samchon/backend) and create a new repository from that.
|
|
86
96
|
|
|
87
97
|
### Manual Installation
|
|
88
|
-
|
|
98
|
+
If you need to manual install, follow below step.
|
|
89
99
|
|
|
90
|
-
|
|
100
|
+
At first, install those dependencies.
|
|
91
101
|
|
|
92
102
|
```sh
|
|
103
|
+
npm install --save nestia-helper
|
|
93
104
|
npm install --save-dev nestia
|
|
94
105
|
|
|
95
106
|
npm install --save-dev typescript
|
|
@@ -97,7 +108,21 @@ npm install --save-dev ttypescript
|
|
|
97
108
|
npm install --save-dev ts-node
|
|
98
109
|
```
|
|
99
110
|
|
|
100
|
-
After the installation, you can
|
|
111
|
+
After the installation, check the `tsconfig.json` file. When you're using nestia, your TypeScript project must be configured to using CommonJS module with strict mode. Also, if you configure plugins like below to using [nestia-helper](https://github.com/samchon/nestia-helper), you can get great benefit by using [pure DTO interface](#pure-dto-interface).
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"compilerOptions": {
|
|
116
|
+
"module": "CommonJS",
|
|
117
|
+
"strict": true,
|
|
118
|
+
"plugins": [
|
|
119
|
+
{ "transform": "nestia-helper/lib/transform" }
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
When all manual setup processes are completed, you can generate the `SDK` or `Swagger`.
|
|
101
126
|
|
|
102
127
|
```sh
|
|
103
128
|
npx nestia sdk "src/**/*.controller" --out "src/api"
|
|
@@ -212,9 +237,9 @@ Look at the below code and feel how powerful `nestia` is.
|
|
|
212
237
|
- 2nd sub-type controller, [`ConsumerSaleQuestionsController`](https://github.com/samchon/nestia/tree/master/demo/generic/src/controllers/ConsumerSaleQuestionsController.ts)
|
|
213
238
|
- Union controller, [`ConsumerSaleEntireArticlesController`](https://github.com/samchon/nestia/tree/master/demo/union/src/controllers/ConsumerSaleEntireArticlesController.ts)
|
|
214
239
|
|
|
215
|
-
Also, you can validate request body data from client automatically, by using [nestia-helper](https://github.com/samchon/nestia-helper) and its `TypedBody()` decorator. Furthermore, `nestia-helper` boosts up JSON string conversion speed about 5x times faster through its `TypedRoute()` component.
|
|
240
|
+
Also, you can validate request body data from client automatically, by using [nestia-helper](https://github.com/samchon/nestia-helper) and its `TypedBody()` decorator, which is maximum 1,000x times faster than other. Furthermore, `nestia-helper` boosts up JSON string conversion speed about 5x times faster through its `TypedRoute()` component.
|
|
216
241
|
|
|
217
|
-

|
|
218
243
|
|
|
219
244
|
```typescript
|
|
220
245
|
import express from "express";
|
|
@@ -433,7 +458,7 @@ Components | `nestia.config.ts` | `CLI` | `@nestjs/swagger`
|
|
|
433
458
|
-----------------------------|--------------------|-------|------------------
|
|
434
459
|
Swagger Generation | ✔ | ✔ | ✔
|
|
435
460
|
SDK Generation | ✔ | ✔ | ❌
|
|
436
|
-
|
|
461
|
+
5x faster `JSON.stringify()` | ✔ | ❌ | ❌
|
|
437
462
|
Type check in runtime | ✔ | ❌ | ❌
|
|
438
463
|
Custom compiler options | ✔ | ❌ | ❌
|
|
439
464
|
|
|
@@ -467,9 +492,12 @@ The detailed options are listed up to the `IConfiguration` interface. You can ut
|
|
|
467
492
|
<summary> Read <code>IConfiguration</code> </summary>
|
|
468
493
|
|
|
469
494
|
```typescript
|
|
495
|
+
import ts from "typescript";
|
|
496
|
+
import type { StripEnums } from "./utils/StripEnums";
|
|
497
|
+
|
|
470
498
|
/**
|
|
471
499
|
* Definition for the `nestia.config.ts` file.
|
|
472
|
-
*
|
|
500
|
+
*
|
|
473
501
|
* @author Jeongho Nam - https://github.com/samchon
|
|
474
502
|
*/
|
|
475
503
|
export interface IConfiguration {
|
|
@@ -505,7 +533,7 @@ export interface IConfiguration {
|
|
|
505
533
|
* }
|
|
506
534
|
* ```
|
|
507
535
|
*/
|
|
508
|
-
compilerOptions?: ts.CompilerOptions
|
|
536
|
+
compilerOptions?: StripEnums<ts.CompilerOptions>;
|
|
509
537
|
|
|
510
538
|
/**
|
|
511
539
|
* Whether to assert parameter types or not.
|
|
@@ -514,6 +542,8 @@ export interface IConfiguration {
|
|
|
514
542
|
* checked through the [typescript-json](https://github.com/samchon/typescript-json#runtime-type-checkers).
|
|
515
543
|
* This option would make your SDK library slower, but would enahcne the type safety even
|
|
516
544
|
* in the runtime level.
|
|
545
|
+
*
|
|
546
|
+
* @default false
|
|
517
547
|
*/
|
|
518
548
|
assert?: boolean;
|
|
519
549
|
|
|
@@ -523,9 +553,26 @@ export interface IConfiguration {
|
|
|
523
553
|
* If you configure this property to be `true`, the SDK library would utilize the
|
|
524
554
|
* [typescript-json](https://github.com/samchon/typescript-json#fastest-json-string-converter)
|
|
525
555
|
* and the JSON string conversion speed really be 2x faster.
|
|
556
|
+
*
|
|
557
|
+
* @default false
|
|
526
558
|
*/
|
|
527
559
|
json?: boolean;
|
|
528
560
|
|
|
561
|
+
/**
|
|
562
|
+
* Whether to wrap DTO by primitive type.
|
|
563
|
+
*
|
|
564
|
+
* If you don't configure this property as `false`, all of DTOs in the
|
|
565
|
+
* SDK library would be automatically wrapped by {@link Primitive} type.
|
|
566
|
+
*
|
|
567
|
+
* For refenrece, if a DTO type be capsuled by the {@link Primitive} type,
|
|
568
|
+
* all of methods in the DTO type would be automatically erased. Also, if
|
|
569
|
+
* the DTO has a `toJSON()` method, the DTO type would be automatically
|
|
570
|
+
* converted to return type of the `toJSON()` method.
|
|
571
|
+
*
|
|
572
|
+
* @default true
|
|
573
|
+
*/
|
|
574
|
+
primitive?: boolean;
|
|
575
|
+
|
|
529
576
|
/**
|
|
530
577
|
* Building `swagger.json` is also possible.
|
|
531
578
|
*
|
|
@@ -564,6 +611,7 @@ export namespace IConfiguration {
|
|
|
564
611
|
output: string;
|
|
565
612
|
}
|
|
566
613
|
}
|
|
614
|
+
|
|
567
615
|
```
|
|
568
616
|
</details>
|
|
569
617
|
|
|
@@ -598,11 +646,79 @@ cd packages/api
|
|
|
598
646
|
npx nestia install
|
|
599
647
|
```
|
|
600
648
|
|
|
601
|
-
###
|
|
602
|
-
https://github.com/samchon/
|
|
649
|
+
### Nestia-Helper
|
|
650
|
+
https://github.com/samchon/nestia-helper
|
|
651
|
+
|
|
652
|
+
If you utilize `nestia` with [nestia-helper](https://github.com/samchon/nestia-helper), you can automatically validatea pure DTO interace without any extra dedication. It analyzes your backend server code in the compilation level and add request body validation code automatically.
|
|
653
|
+
|
|
654
|
+
```typescript
|
|
655
|
+
import helper from "nestia-helper";
|
|
656
|
+
import { Controller } from "@nestjs/common";
|
|
657
|
+
|
|
658
|
+
@Controller("bbs/articles")
|
|
659
|
+
export class BbsArticlesController {
|
|
660
|
+
//----
|
|
661
|
+
// `TSON.stringify()` for `IBbsArticle`
|
|
662
|
+
// Boost up JSON conversion speed about 5x times faster
|
|
663
|
+
//----
|
|
664
|
+
// `TSON.assertType()` for `IBbsArticle.IStore`
|
|
665
|
+
// If client request body is not following type type,
|
|
666
|
+
// `BadRequestException` (status code: 400) would be thrown
|
|
667
|
+
//----
|
|
668
|
+
@helper.TypedRoute.Post()
|
|
669
|
+
public async store(
|
|
670
|
+
// automatic validation
|
|
671
|
+
@helper.TypedBody() input: IBbsArticle.IStore
|
|
672
|
+
): Promise<IBbsArticle> {
|
|
673
|
+
const article: BbsArticle = await BbsArticeProvider.store(input);
|
|
674
|
+
const json: IBbsArticle = await BbsArticleProvider.json().getOne(article);
|
|
675
|
+
|
|
676
|
+
// 5x times faster JSON conversion
|
|
677
|
+
return Paginator.paginate(stmt, input);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
### TypeScript-JSON
|
|
683
|
+
https://github.com/samchon/typescript-json
|
|
684
|
+
|
|
685
|
+
```typescript
|
|
686
|
+
import TSON from "typescript-json";
|
|
687
|
+
|
|
688
|
+
//----
|
|
689
|
+
// RUNTIME VALIDATORS
|
|
690
|
+
//----
|
|
691
|
+
// ALLOW SUPERFLUOUS PROPERTIES
|
|
692
|
+
TSON.assertType<T>(input); // throws exception
|
|
693
|
+
TSON.is<T>(input); // returns boolean value
|
|
694
|
+
TSON.validate<T>(input); // archives all errors
|
|
695
|
+
|
|
696
|
+
// DO NOT ALLOW SUPERFLUOUS PROPERTIES
|
|
697
|
+
TSON.equals<T>(input); // returns boolean value
|
|
698
|
+
TSON.assertEquals<T>(input); // throws exception
|
|
699
|
+
TSON.validateEquals<T>(input); // archives all errors
|
|
700
|
+
|
|
701
|
+
//----
|
|
702
|
+
// APPENDIX FUNCTIONS
|
|
703
|
+
//----
|
|
704
|
+
TSON.stringify<T>(input); // 5x faster JSON.stringify()
|
|
705
|
+
TSON.application<[T, U, V], "swagger">(); // JSON schema application generator
|
|
706
|
+
TSON.create<T>(input); // 2x faster object creator (only one-time construction)
|
|
707
|
+
```
|
|
708
|
+
|
|
709
|
+
`typescript-json` is a transformer library providing JSON related functions.
|
|
710
|
+
|
|
711
|
+
- Powerful Runtime type checkers:
|
|
712
|
+
- Performed by only one line, `TSON.assertType<T>(input)`
|
|
713
|
+
- Only one library which can validate union type
|
|
714
|
+
- Maximum 1,000x faster than other libraries
|
|
715
|
+
- 5x faster `JSON.stringify()` function:
|
|
716
|
+
- Performed by only one line: `TSON.stringify<T>(input)`
|
|
717
|
+
- Only one library which can stringify union type
|
|
718
|
+
- 10,000x faster optimizer construction time than similar libraries
|
|
603
719
|
|
|
604
|
-
|
|
720
|
+
[typescript-json](https://github.com/samchon/typescript-json) analyzes TypeScript source code and generates optimized validators and JSON string converters in the compilation level. It is the reason why `nestia` can generate SDK library is by analyzing NestJS code and how [nestia-helper](https://github.com/samchon/nestia-helper) validates request body data automatically.
|
|
605
721
|
|
|
606
|
-
|
|
722
|
+
Also, its performance enhancement is much greater than other libraries. For example, validator function `TSON.is<T>(input: T): boolean` is maximum 1,000x times faster than other validator libraries.
|
|
607
723
|
|
|
608
|
-
|
|
724
|
+

|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.NestiaStarter = void 0;
|
|
16
16
|
const child_process_1 = __importDefault(require("child_process"));
|
|
17
17
|
const fs_1 = __importDefault(require("fs"));
|
|
18
|
-
const PATH = __dirname + "/../../../template";
|
|
19
18
|
var NestiaStarter;
|
|
20
19
|
(function (NestiaStarter) {
|
|
21
20
|
function start(dest) {
|
|
@@ -29,38 +28,23 @@ var NestiaStarter;
|
|
|
29
28
|
console.log(" Nestia Starter Kit");
|
|
30
29
|
console.log("-----------------------------------------");
|
|
31
30
|
// COPY PROJECTS
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
yield copy(PATH + "/bundle/gitignore", dest + "/.gitignore");
|
|
35
|
-
yield copy(PATH + "/bundle/npmignore", dest + "/.npmignore");
|
|
31
|
+
execute(`git clone https://github.com/samchon/nestia-template ${dest}`);
|
|
32
|
+
console.log(`cd "${dest}"`);
|
|
36
33
|
process.chdir(dest);
|
|
37
34
|
// INSTALL DEPENDENCIES
|
|
38
|
-
|
|
39
|
-
child_process_1.default.execSync("npm install", { stdio: "inherit" });
|
|
35
|
+
execute("npm install");
|
|
40
36
|
// BUILD TYPESCRIPT
|
|
41
|
-
|
|
42
|
-
child_process_1.default.execSync("npm run build", { stdio: "inherit" });
|
|
37
|
+
execute("npm run build");
|
|
43
38
|
// DO TEST
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
execute("npm run test");
|
|
40
|
+
// REMOVE .GIT DIRECTORY
|
|
41
|
+
child_process_1.default.execSync("npx rimraf .git");
|
|
46
42
|
});
|
|
47
43
|
}
|
|
48
44
|
NestiaStarter.start = start;
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (stats.isDirectory()) {
|
|
53
|
-
if (src === PATH + "/.git" || src === PATH + "/bundle")
|
|
54
|
-
return;
|
|
55
|
-
yield fs_1.default.promises.mkdir(dest);
|
|
56
|
-
for (const file of yield fs_1.default.promises.readdir(src))
|
|
57
|
-
yield copy(src + "/" + file, dest + "/" + file);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
const content = yield fs_1.default.promises.readFile(src, "utf8");
|
|
61
|
-
yield fs_1.default.promises.writeFile(dest, content, "utf8");
|
|
62
|
-
}
|
|
63
|
-
});
|
|
45
|
+
function execute(command) {
|
|
46
|
+
console.log(command);
|
|
47
|
+
child_process_1.default.execSync(command, { stdio: "inherit" });
|
|
64
48
|
}
|
|
65
49
|
})(NestiaStarter = exports.NestiaStarter || (exports.NestiaStarter = {}));
|
|
66
50
|
const message = (content) => `Error on nestia.start(): target directory ${content}.`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaStarter.js","sourceRoot":"","sources":["../../../src/executable/internal/NestiaStarter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAA+B;AAC/B,4CAAoB;AAEpB,
|
|
1
|
+
{"version":3,"file":"NestiaStarter.js","sourceRoot":"","sources":["../../../src/executable/internal/NestiaStarter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kEAA+B;AAC/B,4CAAoB;AAEpB,IAAiB,aAAa,CAiC7B;AAjCD,WAAiB,aAAa;IAC1B,SAAsB,KAAK,CAAC,IAAwB;;YAChD,aAAa;YACb,IAAI,IAAI,KAAK,SAAS;gBAAE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC;iBACjE,IAAI,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,IAAI;gBACjC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;YAE/C,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;YACzD,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;YAEzD,gBAAgB;YAChB,OAAO,CAAC,wDAAwD,IAAI,EAAE,CAAC,CAAC;YACxE,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAEpB,uBAAuB;YACvB,OAAO,CAAC,aAAa,CAAC,CAAC;YAEvB,mBAAmB;YACnB,OAAO,CAAC,eAAe,CAAC,CAAC;YAEzB,UAAU;YACV,OAAO,CAAC,cAAc,CAAC,CAAC;YAExB,wBAAwB;YACxB,uBAAE,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QACnC,CAAC;KAAA;IA1BqB,mBAAK,QA0B1B,CAAA;IAED,SAAS,OAAO,CAAC,OAAe;QAC5B,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACrB,uBAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/C,CAAC;AACL,CAAC,EAjCgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAiC7B;AAED,MAAM,OAAO,GAAG,CAAC,OAAe,EAAE,EAAE,CAChC,6CAA6C,OAAO,GAAG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nestia",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"description": "Automatic SDK and Document generator for the NestJS",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"tsconfck": "^2.0.1",
|
|
44
44
|
"tsconfig-paths": "^4.0.0",
|
|
45
45
|
"tstl": "^2.5.12",
|
|
46
|
-
"typescript-json": "^3.3.
|
|
46
|
+
"typescript-json": "^3.3.11"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/cli": "^0.11.19",
|
package/template/.eslintrc.cjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
root: true,
|
|
3
|
-
plugins: [
|
|
4
|
-
"@typescript-eslint"
|
|
5
|
-
],
|
|
6
|
-
extends: [
|
|
7
|
-
"plugin:@typescript-eslint/recommended",
|
|
8
|
-
],
|
|
9
|
-
parser: "@typescript-eslint/parser",
|
|
10
|
-
parserOptions: {
|
|
11
|
-
project: "tsconfig.json"
|
|
12
|
-
},
|
|
13
|
-
overrides: [
|
|
14
|
-
{
|
|
15
|
-
files: ["src/**/*.ts"],
|
|
16
|
-
rules: {
|
|
17
|
-
"@typescript-eslint/no-duplicate-imports": "error",
|
|
18
|
-
"@typescript-eslint/no-floating-promises": "error"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
name: build
|
|
2
|
-
on: [push, pull_request]
|
|
3
|
-
|
|
4
|
-
jobs:
|
|
5
|
-
Ubuntu:
|
|
6
|
-
runs-on: ubuntu-latest
|
|
7
|
-
steps:
|
|
8
|
-
- uses: actions/checkout@v3
|
|
9
|
-
- uses: actions/setup-node@v3
|
|
10
|
-
|
|
11
|
-
- name: Install Backend-Server
|
|
12
|
-
run: npm install
|
|
13
|
-
|
|
14
|
-
- name: Compile Backend-Server
|
|
15
|
-
run: npm run build
|
|
16
|
-
|
|
17
|
-
- name: Test Backend-Server
|
|
18
|
-
run: npm run test
|
package/template/.prettierignore
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// Use IntelliSense to learn about possible Node.js debug attributes.
|
|
3
|
-
// Hover to view descriptions of existing attributes.
|
|
4
|
-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
-
"version": "0.2.0",
|
|
6
|
-
"configurations": [
|
|
7
|
-
{
|
|
8
|
-
"type": "node",
|
|
9
|
-
"request": "launch",
|
|
10
|
-
"name": "JavaScript Test using SourceMap",
|
|
11
|
-
"program": "${workspaceRoot}/bin/test/index.js",
|
|
12
|
-
"cwd": "${workspaceRoot}",
|
|
13
|
-
|
|
14
|
-
// TypeScript
|
|
15
|
-
"sourceMaps": true,
|
|
16
|
-
"outFiles": ["${workspaceRot}/**.js"]
|
|
17
|
-
}
|
|
18
|
-
]
|
|
19
|
-
}
|
package/template/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Jeongho Nam
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/template/README.md
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# Nestia Template
|
|
2
|
-
## Outline
|
|
3
|
-
[](https://github.com/samchon/nestia-template/actions?query=workflow%3Abuild)
|
|
4
|
-
|
|
5
|
-
A template repository for backend projects using [nestia](https://github.com/samchon/nestia).
|
|
6
|
-
|
|
7
|
-
You can create a new project from this boilerplate by running below command:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npx nestia start <directory>
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
For reference, this is a minimal boilerplate project concentrating only on [nestia](https://github.com/samchon/nestia) SDK generation. If you wanna much detailed boilerplate project even configured DB and Non-distruptive update system, visit [samchon/backend](https://github.com/samchon/backend) and create a new repository from that.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Directories and Files
|
|
19
|
-
This template project has categorized directories like below.
|
|
20
|
-
|
|
21
|
-
As you can see from the below, all of the TypeScript source files are placed into the [src](src/) directory. When you build the TypeScript source files, compiled files would be placed into the `bin` 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.
|
|
22
|
-
|
|
23
|
-
- [packages/api/](packages/api): SDK module built by `npm run build:api`
|
|
24
|
-
- [src/](src): TypeScript source directory
|
|
25
|
-
- [src/api/](src/api/): Client SDK that would be published to the `@ORGANIZATION/PROJECT-api`
|
|
26
|
-
- [**src/api/functional/**](src/api/functional/): API functions generated by the [`nestia`](https://github.com/samchon/nestia)
|
|
27
|
-
- [**src/api/structures/**](src/api/structures/): DTO structures
|
|
28
|
-
- [src/controllers/](src/controllers/): Controller classes of the Main Program
|
|
29
|
-
- [**src/test/**](src/test/): Test Automation Program
|
|
30
|
-
- [nestia.config.ts](nestia.config.ts): Configuration file of [`nestia`](https://github.com/samchon/nestia)
|
|
31
|
-
- [package.json](package.json): NPM configuration
|
|
32
|
-
- [tsconfig.json](tsconfig.json): TypeScript configuration for the main program
|
|
33
|
-
- [tsconfig.api.json](tsconfig.api.json): TypeScript configuration for the SDK generation
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## NPM Run Commands
|
|
39
|
-
List of the run commands defined in the [package.json](package.json) are like below:
|
|
40
|
-
|
|
41
|
-
- `build`: Compile the source code
|
|
42
|
-
- `build:api`: Build client SDK libray for the client developers
|
|
43
|
-
- `build:sdk`: Build SDK into main program only
|
|
44
|
-
- `build:swagger`: Build Swagger Documents
|
|
45
|
-
- `dev`: Incremental build for development
|
|
46
|
-
- `eslint` & `eslint:fix` & `prettier`: Prettier and ESLint execution
|
|
47
|
-
- `test`: Run test automation program
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
## Specialization
|
|
53
|
-
Transform this template project to be yours.
|
|
54
|
-
|
|
55
|
-
When 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.
|
|
56
|
-
|
|
57
|
-
| Before | After
|
|
58
|
-
|-----------------|----------------------------------------
|
|
59
|
-
| ORGANIZATION | Your account or corporation name
|
|
60
|
-
| PROJECT | Your own project name
|
|
61
|
-
| AUTHOR | Author name
|
|
62
|
-
| https://github.com/samchon/nestia-template | Your repository URL
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
## Test Driven Development
|
|
68
|
-
With [nestia](https://github.com/samchon/nestia) helps to accomplish TDD (Test Driven Development).
|
|
69
|
-
|
|
70
|
-
Just 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.
|
|
71
|
-
|
|
72
|
-
During 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.
|
|
73
|
-
|
|
74
|
-
> Visit the [samchon/backend](https://github.com/samchon/backend), then you may find much detailed story about this TDD.
|
|
75
|
-
>
|
|
76
|
-
> 1. Definitions
|
|
77
|
-
> 2. SDK
|
|
78
|
-
> 3. Test Automation Program
|
|
79
|
-
> 4. Main Program
|
|
80
|
-
|
|
81
|
-
```typescript
|
|
82
|
-
import TSON from "typescript-json";
|
|
83
|
-
|
|
84
|
-
import api from "@ORGANIZATION/PROJECT-api/lib/index";
|
|
85
|
-
import { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/bbs/IBbsArticle";
|
|
86
|
-
|
|
87
|
-
import { ArrayUtil } from "../../../../utils/ArrayUtil";
|
|
88
|
-
import { GaffComparator } from "../../../internal/GaffComparator";
|
|
89
|
-
import { RandomGenerator } from "../../../internal/RandomGenerator";
|
|
90
|
-
import { validate_index_sort } from "../../../internal/validate_index_sort";
|
|
91
|
-
|
|
92
|
-
export async function test_api_bbs_article_index_sort(
|
|
93
|
-
connection: api.IConnection,
|
|
94
|
-
): Promise<void> {
|
|
95
|
-
// GENERATE 100 ARTICLES
|
|
96
|
-
const section: string = "general";
|
|
97
|
-
const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>
|
|
98
|
-
api.functional.bbs.articles.store(connection, section, {
|
|
99
|
-
writer: RandomGenerator.name(),
|
|
100
|
-
title: RandomGenerator.paragraph(),
|
|
101
|
-
body: RandomGenerator.content(),
|
|
102
|
-
format: "txt",
|
|
103
|
-
files: [],
|
|
104
|
-
password: RandomGenerator.alphabets(8),
|
|
105
|
-
}),
|
|
106
|
-
);
|
|
107
|
-
TSON.assertEquals(articles);
|
|
108
|
-
|
|
109
|
-
// PREPARE VALIDATOR
|
|
110
|
-
const validator = validate_index_sort("BbsArticleProvider.idex()")(
|
|
111
|
-
(input: IBbsArticle.IRequest) =>
|
|
112
|
-
api.functional.bbs.articles.index(connection, section, input),
|
|
113
|
-
);
|
|
114
|
-
|
|
115
|
-
// DO VALIDATE
|
|
116
|
-
const components = [
|
|
117
|
-
validator("created_at")(GaffComparator.dates((x) => x.created_at)),
|
|
118
|
-
validator("updated_at")(GaffComparator.dates((x) => x.updated_at)),
|
|
119
|
-
validator("title")(GaffComparator.strings((x) => x.title)),
|
|
120
|
-
validator("writer")(GaffComparator.strings((x) => x.writer)),
|
|
121
|
-
validator(
|
|
122
|
-
"writer",
|
|
123
|
-
"title",
|
|
124
|
-
)(GaffComparator.strings((x) => [x.writer, x.title])),
|
|
125
|
-
];
|
|
126
|
-
for (const comp of components) {
|
|
127
|
-
await comp("+");
|
|
128
|
-
await comp("-");
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
```
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// nestia configuration file
|
|
2
|
-
import type nestia from "nestia";
|
|
3
|
-
|
|
4
|
-
const NESTIA_CONFIG: nestia.IConfiguration = {
|
|
5
|
-
input: "src/controllers",
|
|
6
|
-
output: "src/api",
|
|
7
|
-
swagger: {
|
|
8
|
-
output: "dist/swagger.json",
|
|
9
|
-
},
|
|
10
|
-
primitive: false,
|
|
11
|
-
};
|
|
12
|
-
export default NESTIA_CONFIG;
|
package/template/package.json
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@ORGANIZATION/PROJECT",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"description": "Starter kit of Nestia",
|
|
5
|
-
"main": "bin/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"build": "rimraf bin && ttsc",
|
|
8
|
-
"build:api": "rimraf packages/api/lib && npm run build:sdk && ttsc -p tsconfig.api.json",
|
|
9
|
-
"build:sdk": "npx nestia sdk",
|
|
10
|
-
"build:swagger": "npx nestia swagger",
|
|
11
|
-
"eslint": "eslint src",
|
|
12
|
-
"eslint:fix": "eslint src --fix",
|
|
13
|
-
"dev": "rimraf bin && ttsc --watch",
|
|
14
|
-
"prettier": "prettier src --write",
|
|
15
|
-
"test": "node bin/test"
|
|
16
|
-
},
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "https://github.com/samchon/nestia-template"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"nestia",
|
|
23
|
-
"template",
|
|
24
|
-
"boilerplate"
|
|
25
|
-
],
|
|
26
|
-
"author": "AUTHOR",
|
|
27
|
-
"license": "MIT",
|
|
28
|
-
"bugs": {
|
|
29
|
-
"url": "https://github.com/samchon/nestia-template/issues"
|
|
30
|
-
},
|
|
31
|
-
"homepage": "https://github.com/samchon/nestia-template#readme",
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@trivago/prettier-plugin-sort-imports": "^3.3.1",
|
|
34
|
-
"@types/cli": "^0.11.21",
|
|
35
|
-
"@types/express": "^4.17.14",
|
|
36
|
-
"@types/node": "^18.11.0",
|
|
37
|
-
"@types/uuid": "^8.3.4",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^5.40.0",
|
|
39
|
-
"@typescript-eslint/parser": "^5.40.0",
|
|
40
|
-
"chalk": "^4.1.0",
|
|
41
|
-
"cli": "^1.0.1",
|
|
42
|
-
"nestia": "^3.1.1",
|
|
43
|
-
"prettier": "^2.7.1",
|
|
44
|
-
"rimraf": "^3.0.2",
|
|
45
|
-
"source-map-support": "^0.5.21",
|
|
46
|
-
"ts-node": "^10.9.1",
|
|
47
|
-
"ttypescript": "^1.5.13",
|
|
48
|
-
"typescript": "^4.8.4",
|
|
49
|
-
"typescript-transform-paths": "^3.3.1"
|
|
50
|
-
},
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"@nestjs/common": "^9.1.4",
|
|
53
|
-
"@nestjs/core": "^9.1.4",
|
|
54
|
-
"@nestjs/platform-express": "^9.1.4",
|
|
55
|
-
"nestia-helper": "^3.1.6",
|
|
56
|
-
"raw-body": "^2.5.1",
|
|
57
|
-
"rxjs": "^7.5.7",
|
|
58
|
-
"tstl": "^2.5.12",
|
|
59
|
-
"typescript-json": "^3.3.10",
|
|
60
|
-
"uuid": "^9.0.0"
|
|
61
|
-
}
|
|
62
|
-
}
|