nestia 3.1.0 → 3.1.1-dev.20221016
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/.eslintrc.cjs +33 -0
- package/.prettierignore +5 -0
- package/.vscode/settings.json +10 -0
- package/demo/encrypted/src/Backend.ts +27 -0
- package/demo/encrypted/src/Configuration.ts +7 -0
- package/demo/encrypted/src/api/HttpError.ts +1 -0
- package/demo/encrypted/src/api/IConnection.ts +1 -0
- package/demo/encrypted/src/api/Primitive.ts +1 -0
- package/demo/encrypted/src/api/__internal/AesPkcs5.ts +1 -0
- package/demo/encrypted/src/api/__internal/Fetcher.ts +1 -0
- package/demo/encrypted/src/api/functional/index.ts +7 -0
- package/demo/encrypted/src/api/functional/sellers/authenticate/index.ts +136 -0
- package/demo/encrypted/src/api/functional/sellers/authenticate/password/index.ts +53 -0
- package/demo/encrypted/src/api/functional/sellers/index.ts +7 -0
- package/demo/encrypted/src/api/index.ts +9 -0
- package/demo/encrypted/src/api/module.ts +10 -0
- package/demo/encrypted/src/api/structures/ISeller.ts +56 -0
- package/demo/encrypted/src/controllers/SellerAuthenticateController.ts +70 -0
- package/demo/encrypted/src/test/features/test_seller_exit.ts +18 -0
- package/demo/encrypted/src/test/features/test_seller_join.ts +19 -0
- package/demo/encrypted/src/test/features/test_seller_login.ts +16 -0
- package/demo/encrypted/src/test/features/test_seller_password_change.ts +18 -0
- package/demo/encrypted/src/test/index.ts +24 -0
- package/demo/encrypted/src/test/internal/DynamicImportIterator.ts +109 -0
- package/demo/encrypted/src/test/internal/StopWatch.ts +15 -0
- package/demo/encrypted/swagger.json +257 -0
- package/demo/encrypted/tsconfig.json +8 -0
- package/demo/generic/nestia.config.ts +10 -0
- package/demo/generic/src/Backend.ts +27 -0
- package/demo/generic/src/Configuration.ts +7 -0
- package/demo/generic/src/api/HttpError.ts +1 -0
- package/demo/generic/src/api/IConnection.ts +1 -0
- package/demo/generic/src/api/Primitive.ts +1 -0
- package/demo/generic/src/api/__internal/AesPkcs5.ts +1 -0
- package/demo/generic/src/api/__internal/Fetcher.ts +1 -0
- package/demo/generic/src/api/functional/consumers/index.ts +7 -0
- package/demo/generic/src/api/functional/consumers/sales/index.ts +8 -0
- package/demo/generic/src/api/functional/consumers/sales/questions/index.ts +136 -0
- package/demo/generic/src/api/functional/consumers/sales/reviews/index.ts +136 -0
- package/demo/generic/src/api/functional/index.ts +7 -0
- package/demo/generic/src/api/index.ts +9 -0
- package/demo/generic/src/api/module.ts +10 -0
- package/demo/generic/src/api/structures/IAttachmentFile.ts +21 -0
- package/demo/generic/src/api/structures/ISaleArticle.ts +79 -0
- package/demo/generic/src/api/structures/ISaleInquiry.ts +34 -0
- package/demo/generic/src/api/structures/ISaleInquiryAnswer.ts +23 -0
- package/demo/generic/src/api/structures/ISaleQuestion.ts +22 -0
- package/demo/generic/src/api/structures/ISaleReview.ts +32 -0
- package/demo/generic/src/controllers/ConsumerSaleQuestionsController.ts +33 -0
- package/demo/generic/src/controllers/ConsumerSaleReviewsController.ts +34 -0
- package/demo/generic/src/controllers/SaleInquiriesController.ts +87 -0
- package/demo/generic/src/test/features/test_question_store.ts +21 -0
- package/demo/generic/src/test/features/test_question_update.ts +42 -0
- package/demo/generic/src/test/features/test_review_store.ts +22 -0
- package/demo/generic/src/test/features/test_review_update.ts +44 -0
- package/demo/generic/src/test/index.ts +24 -0
- package/demo/generic/src/test/internal/DynamicImportIterator.ts +109 -0
- package/demo/generic/src/test/internal/StopWatch.ts +15 -0
- package/demo/generic/swagger.json +736 -0
- package/demo/generic/tsconfig.json +9 -0
- package/demo/multiple-paths/src/Backend.ts +27 -0
- package/demo/multiple-paths/src/Configuration.ts +7 -0
- package/demo/multiple-paths/src/api/HttpError.ts +1 -0
- package/demo/multiple-paths/src/api/IConnection.ts +1 -0
- package/demo/multiple-paths/src/api/Primitive.ts +1 -0
- package/demo/multiple-paths/src/api/__internal/AesPkcs5.ts +1 -0
- package/demo/multiple-paths/src/api/__internal/Fetcher.ts +1 -0
- package/demo/multiple-paths/src/api/functional/consumers/index.ts +7 -0
- package/demo/multiple-paths/src/api/functional/consumers/sales/articles/comments/index.ts +65 -0
- package/demo/multiple-paths/src/api/functional/consumers/sales/articles/index.ts +7 -0
- package/demo/multiple-paths/src/api/functional/consumers/sales/index.ts +7 -0
- package/demo/multiple-paths/src/api/functional/health/alive/index.ts +42 -0
- package/demo/multiple-paths/src/api/functional/health/index.ts +44 -0
- package/demo/multiple-paths/src/api/functional/healthy/alive/index.ts +42 -0
- package/demo/multiple-paths/src/api/functional/healthy/index.ts +44 -0
- package/demo/multiple-paths/src/api/functional/index.ts +10 -0
- package/demo/multiple-paths/src/api/functional/sellers/index.ts +7 -0
- package/demo/multiple-paths/src/api/functional/sellers/sales/articles/comments/index.ts +65 -0
- package/demo/multiple-paths/src/api/functional/sellers/sales/articles/index.ts +7 -0
- package/demo/multiple-paths/src/api/functional/sellers/sales/index.ts +7 -0
- package/demo/multiple-paths/src/api/index.ts +9 -0
- package/demo/multiple-paths/src/api/module.ts +10 -0
- package/demo/multiple-paths/src/api/structures/ISaleArticleComment.ts +93 -0
- package/demo/multiple-paths/src/controllers/HealthController.ts +7 -0
- package/demo/multiple-paths/src/controllers/MultipleController.ts +56 -0
- package/demo/multiple-paths/src/test/features/test_consumer_sale_article_comment_store.ts +21 -0
- package/demo/multiple-paths/src/test/features/test_health_checks.ts +10 -0
- package/demo/multiple-paths/src/test/features/test_seller_sale_article_store.ts +21 -0
- package/demo/multiple-paths/src/test/index.ts +24 -0
- package/demo/multiple-paths/src/test/internal/DynamicImportIterator.ts +109 -0
- package/demo/multiple-paths/src/test/internal/StopWatch.ts +15 -0
- package/demo/multiple-paths/swagger.json +338 -0
- package/demo/multiple-paths/tsconfig.json +3 -0
- package/demo/recursive/src/Backend.ts +27 -0
- package/demo/recursive/src/Configuration.ts +7 -0
- package/demo/recursive/src/api/HttpError.ts +1 -0
- package/demo/recursive/src/api/IConnection.ts +1 -0
- package/demo/recursive/src/api/Primitive.ts +1 -0
- package/demo/recursive/src/api/__internal/AesPkcs5.ts +1 -0
- package/demo/recursive/src/api/__internal/Fetcher.ts +1 -0
- package/demo/recursive/src/api/functional/consumers/index.ts +7 -0
- package/demo/recursive/src/api/functional/consumers/systematic/categories/index.ts +117 -0
- package/demo/recursive/src/api/functional/consumers/systematic/index.ts +7 -0
- package/demo/recursive/src/api/functional/index.ts +7 -0
- package/demo/recursive/src/api/index.ts +9 -0
- package/demo/recursive/src/api/module.ts +10 -0
- package/demo/recursive/src/api/structures/ICategory.ts +49 -0
- package/demo/recursive/src/consumer.categories.controller.ts +59 -0
- package/demo/recursive/src/test/features/test_category_at.ts +11 -0
- package/demo/recursive/src/test/features/test_category_invert.ts +14 -0
- package/demo/recursive/src/test/features/test_category_top.ts +11 -0
- package/demo/recursive/src/test/index.ts +24 -0
- package/demo/recursive/src/test/internal/DynamicImportIterator.ts +109 -0
- package/demo/recursive/src/test/internal/StopWatch.ts +15 -0
- package/demo/recursive/swagger.json +216 -0
- package/demo/recursive/tsconfig.json +3 -0
- package/demo/safe/nestia.config.ts +13 -0
- package/demo/safe/src/Backend.ts +27 -0
- package/demo/safe/src/Configuration.ts +7 -0
- package/demo/safe/src/api/HttpError.ts +1 -0
- package/demo/safe/src/api/IConnection.ts +1 -0
- package/demo/safe/src/api/Primitive.ts +1 -0
- package/demo/safe/src/api/__internal/AesPkcs5.ts +1 -0
- package/demo/safe/src/api/__internal/Fetcher.ts +1 -0
- package/demo/safe/src/api/functional/consumers/index.ts +7 -0
- package/demo/safe/src/api/functional/consumers/sales/articles/comments/index.ts +69 -0
- package/demo/safe/src/api/functional/consumers/sales/articles/index.ts +7 -0
- package/demo/safe/src/api/functional/consumers/sales/index.ts +7 -0
- package/demo/safe/src/api/functional/index.ts +7 -0
- package/demo/safe/src/api/index.ts +9 -0
- package/demo/safe/src/api/module.ts +10 -0
- package/demo/safe/src/api/structures/ISaleArticleComment.ts +93 -0
- package/demo/safe/src/controllers/ConsumerSaleArticleCommentsController.ts +63 -0
- package/demo/safe/src/test/features/test_comment_store.ts +23 -0
- package/demo/safe/src/test/index.ts +24 -0
- package/demo/safe/src/test/internal/DynamicImportIterator.ts +109 -0
- package/demo/safe/src/test/internal/StopWatch.ts +15 -0
- package/demo/safe/swagger.json +217 -0
- package/demo/safe/tsconfig.json +3 -0
- package/demo/tsconfig.base.json +70 -0
- package/demo/union/nestia.config.ts +9 -0
- package/demo/union/src/Backend.ts +27 -0
- package/demo/union/src/Configuration.ts +7 -0
- package/demo/union/src/api/HttpError.ts +1 -0
- package/demo/union/src/api/IConnection.ts +1 -0
- package/demo/union/src/api/Primitive.ts +1 -0
- package/demo/union/src/api/__internal/AesPkcs5.ts +1 -0
- package/demo/union/src/api/__internal/Fetcher.ts +1 -0
- package/demo/union/src/api/functional/consumers/index.ts +7 -0
- package/demo/union/src/api/functional/consumers/sales/entire_articles/index.ts +121 -0
- package/demo/union/src/api/functional/consumers/sales/index.ts +9 -0
- package/demo/union/src/api/functional/consumers/sales/questions/index.ts +57 -0
- package/demo/union/src/api/functional/consumers/sales/reviews/index.ts +54 -0
- package/demo/union/src/api/functional/index.ts +7 -0
- package/demo/union/src/api/index.ts +9 -0
- package/demo/union/src/api/module.ts +10 -0
- package/demo/union/src/api/structures/IAttachmentFile.ts +26 -0
- package/demo/union/src/api/structures/IPage.ts +80 -0
- package/demo/union/src/api/structures/ISaleArticle.ts +107 -0
- package/demo/union/src/api/structures/ISaleEntireArticle.ts +22 -0
- package/demo/union/src/api/structures/ISaleInquiry.ts +56 -0
- package/demo/union/src/api/structures/ISaleInquiryAnswer.ts +23 -0
- package/demo/union/src/api/structures/ISaleQuestion.ts +27 -0
- package/demo/union/src/api/structures/ISaleReview.ts +42 -0
- package/demo/union/src/controllers/ConsumerSaleEntireArticlesController.ts +109 -0
- package/demo/union/src/controllers/ConsumerSaleQuestionsController.ts +45 -0
- package/demo/union/src/controllers/ConsumerSaleReviewsController.ts +44 -0
- package/demo/union/src/test/features/test_sale_entire_articles_at.ts +16 -0
- package/demo/union/src/test/features/test_sale_entire_articles_index.ts +27 -0
- package/demo/union/src/test/index.ts +24 -0
- package/demo/union/src/test/internal/DynamicImportIterator.ts +109 -0
- package/demo/union/src/test/internal/StopWatch.ts +15 -0
- package/demo/union/swagger.json +991 -0
- package/demo/union/tsconfig.json +3 -0
- package/lib/test/TestBuilder.d.ts +4 -0
- package/lib/test/TestBuilder.js +60 -0
- package/lib/test/TestBuilder.js.map +1 -0
- package/lib/test/index.d.ts +1 -0
- package/lib/test/index.js +61 -0
- package/lib/test/index.js.map +1 -0
- package/lib/test/test.builder.executor.d.ts +1 -0
- package/lib/test/test.builder.executor.js +24 -0
- package/lib/test/test.builder.executor.js.map +1 -0
- package/package.json +1 -1
- package/prettier.config.js +7 -0
- package/src/IConfiguration.ts +119 -0
- package/src/NestiaApplication.ts +185 -0
- package/src/analyses/ControllerAnalyzer.ts +204 -0
- package/src/analyses/GenericAnalyzer.ts +53 -0
- package/src/analyses/ImportAnalyzer.ts +144 -0
- package/src/analyses/PathAnalyzer.ts +58 -0
- package/src/analyses/ReflectAnalyzer.ts +280 -0
- package/src/analyses/SourceFinder.ts +59 -0
- package/src/executable/internal/CompilerOptions.ts +18 -0
- package/src/executable/internal/NestiaCommand.ts +174 -0
- package/src/executable/internal/NestiaConfig.ts +36 -0
- package/src/executable/internal/NestiaStarter.ts +45 -0
- package/src/executable/internal/nestia.config.getter.ts +11 -0
- package/src/executable/nestia.ts +55 -0
- package/src/generates/FileGenerator.ts +156 -0
- package/src/generates/FunctionGenerator.ts +287 -0
- package/src/generates/SdkGenerator.ts +49 -0
- package/src/generates/SwaggerGenerator.ts +381 -0
- package/src/index.ts +2 -0
- package/src/module.ts +2 -0
- package/src/structures/IController.ts +27 -0
- package/src/structures/IRoute.ts +28 -0
- package/src/structures/ISwagger.ts +55 -0
- package/src/structures/ITypeTuple.ts +6 -0
- package/src/structures/MethodType.ts +11 -0
- package/src/structures/ParamCategory.ts +1 -0
- package/src/structures/TypeEntry.ts +22 -0
- package/src/test/TestBuilder.ts +49 -0
- package/src/test/index.ts +59 -0
- package/src/test/test.builder.executor.ts +11 -0
- package/src/utils/ArrayUtil.ts +26 -0
- package/src/utils/DirectoryUtil.ts +44 -0
- package/src/utils/ImportDictionary.ts +57 -0
- package/src/utils/MapUtil.ts +14 -0
- package/src/utils/StripEnums.ts +10 -0
- package/template/.eslintrc.cjs +22 -0
- package/template/.prettierignore +6 -0
- package/template/prettier.config.js +18 -0
- package/template/tsconfig.json +118 -0
- package/tsconfig.json +82 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module api
|
|
4
|
+
*/
|
|
5
|
+
//================================================================
|
|
6
|
+
export * from "./IConnection";
|
|
7
|
+
export * from "./Primitive";
|
|
8
|
+
export * from "./HttpError";
|
|
9
|
+
|
|
10
|
+
export * as functional from "./functional";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Systematic category info.
|
|
3
|
+
*
|
|
4
|
+
* This `ICategory` has been designed to represent a systematic classfication. Also, its
|
|
5
|
+
* classification has hierarchical and recursive relationship. Therefore, its structure has
|
|
6
|
+
* a tree shape through the {@link ICategory.children} property.
|
|
7
|
+
*
|
|
8
|
+
* If you want to see invert structure for getting parent information repeatedly, use the
|
|
9
|
+
* {@link ICategory.IInvert} type instead.
|
|
10
|
+
*
|
|
11
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
12
|
+
*/
|
|
13
|
+
export interface ICategory extends ICategory.IBase {
|
|
14
|
+
/**
|
|
15
|
+
* Children categories.
|
|
16
|
+
*/
|
|
17
|
+
children: ICategory[];
|
|
18
|
+
}
|
|
19
|
+
export namespace ICategory {
|
|
20
|
+
/**
|
|
21
|
+
* Invert structure of the {@link ICategory}.
|
|
22
|
+
*/
|
|
23
|
+
export interface IInvert extends IBase {
|
|
24
|
+
/**
|
|
25
|
+
* Parent information.
|
|
26
|
+
*/
|
|
27
|
+
parent: IInvert | null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Basic information of the {@link ICategory}.
|
|
32
|
+
*/
|
|
33
|
+
export interface IBase {
|
|
34
|
+
/**
|
|
35
|
+
* Primary Key.
|
|
36
|
+
*/
|
|
37
|
+
id: number;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Identifier code.
|
|
41
|
+
*/
|
|
42
|
+
code: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Name of the category.
|
|
46
|
+
*/
|
|
47
|
+
name: string;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as nest from "@nestjs/common";
|
|
2
|
+
import helper from "nestia-helper";
|
|
3
|
+
import { randint } from "tstl/algorithm/random";
|
|
4
|
+
|
|
5
|
+
import { ICategory } from "./api/structures/ICategory";
|
|
6
|
+
|
|
7
|
+
@nest.Controller("consumers/systematic/categories")
|
|
8
|
+
export class ConsumerCategoriesController {
|
|
9
|
+
@nest.Get()
|
|
10
|
+
public async top(): Promise<ICategory[]> {
|
|
11
|
+
return generate_random_categories();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@nest.Get(":id")
|
|
15
|
+
public async at(
|
|
16
|
+
@helper.TypedParam("id", "number") id: number,
|
|
17
|
+
): Promise<ICategory> {
|
|
18
|
+
const category: ICategory = generate_random_categories(1)[0];
|
|
19
|
+
category.id = id;
|
|
20
|
+
return category;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@nest.Get(":id/invert")
|
|
24
|
+
public async invert(
|
|
25
|
+
@helper.TypedParam("id", "number") id: number,
|
|
26
|
+
): Promise<ICategory.IInvert> {
|
|
27
|
+
return {
|
|
28
|
+
id,
|
|
29
|
+
code: "target",
|
|
30
|
+
name: "target",
|
|
31
|
+
parent: {
|
|
32
|
+
id: 1,
|
|
33
|
+
code: "parent",
|
|
34
|
+
name: "parent",
|
|
35
|
+
parent: {
|
|
36
|
+
id: 2,
|
|
37
|
+
code: "grandparent",
|
|
38
|
+
name: "grandparent",
|
|
39
|
+
parent: {
|
|
40
|
+
id: 3,
|
|
41
|
+
code: "root",
|
|
42
|
+
name: "root",
|
|
43
|
+
parent: null,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function generate_random_categories(level: number = 0): ICategory[] {
|
|
52
|
+
if (level === 3) return [];
|
|
53
|
+
return new Array(randint(2, 5)).fill("").map(() => ({
|
|
54
|
+
id: randint(1, 100),
|
|
55
|
+
code: "code",
|
|
56
|
+
name: "name",
|
|
57
|
+
children: generate_random_categories(level + 1),
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import api from "../../api";
|
|
2
|
+
import { ICategory } from "../../api/structures/ICategory";
|
|
3
|
+
import TSON from "typescript-json";
|
|
4
|
+
|
|
5
|
+
export async function test_category_at(
|
|
6
|
+
connection: api.IConnection,
|
|
7
|
+
): Promise<void> {
|
|
8
|
+
const category: ICategory =
|
|
9
|
+
await api.functional.consumers.systematic.categories.at(connection, 0);
|
|
10
|
+
TSON.assertType(category);
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import api from "../../api";
|
|
2
|
+
import { ICategory } from "../../api/structures/ICategory";
|
|
3
|
+
import TSON from "typescript-json";
|
|
4
|
+
|
|
5
|
+
export async function test_category_invert(
|
|
6
|
+
connection: api.IConnection,
|
|
7
|
+
): Promise<void> {
|
|
8
|
+
const category: ICategory.IInvert =
|
|
9
|
+
await api.functional.consumers.systematic.categories.invert(
|
|
10
|
+
connection,
|
|
11
|
+
0,
|
|
12
|
+
);
|
|
13
|
+
TSON.assertType(category);
|
|
14
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import api from "../../api";
|
|
2
|
+
import { ICategory } from "../../api/structures/ICategory";
|
|
3
|
+
import TSON from "typescript-json";
|
|
4
|
+
|
|
5
|
+
export async function test_category_top(
|
|
6
|
+
connection: api.IConnection,
|
|
7
|
+
): Promise<void> {
|
|
8
|
+
const categories: ICategory[] =
|
|
9
|
+
await api.functional.consumers.systematic.categories.top(connection);
|
|
10
|
+
TSON.assertType(categories);
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import api from "../api";
|
|
2
|
+
import { Backend } from "../Backend";
|
|
3
|
+
import { Configuration } from "../Configuration";
|
|
4
|
+
import { DynamicImportIterator } from "./internal/DynamicImportIterator";
|
|
5
|
+
|
|
6
|
+
async function main(): Promise<void> {
|
|
7
|
+
const server: Backend = new Backend();
|
|
8
|
+
await server.open();
|
|
9
|
+
|
|
10
|
+
const connection: api.IConnection = {
|
|
11
|
+
host: `http://127.0.0.1:${Configuration.PORT}`,
|
|
12
|
+
encryption: Configuration.ENCRYPTION_PASSWORD,
|
|
13
|
+
};
|
|
14
|
+
await DynamicImportIterator.main(__dirname, {
|
|
15
|
+
prefix: "test",
|
|
16
|
+
parameters: () => [connection],
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
await server.close();
|
|
20
|
+
}
|
|
21
|
+
main().catch((exp) => {
|
|
22
|
+
console.log(exp);
|
|
23
|
+
process.exit(-1);
|
|
24
|
+
});
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const EXTENSION = __filename.substr(-2);
|
|
2
|
+
|
|
3
|
+
import cli from "cli";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import { IPointer } from "tstl/functional/IPointer";
|
|
6
|
+
|
|
7
|
+
import { StopWatch } from "./StopWatch";
|
|
8
|
+
|
|
9
|
+
interface ICommand {
|
|
10
|
+
include?: string;
|
|
11
|
+
exclude?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export namespace DynamicImportIterator {
|
|
15
|
+
export type Closure<Arguments extends any[]> = (
|
|
16
|
+
...args: Arguments
|
|
17
|
+
) => Promise<any>;
|
|
18
|
+
type Module<Arguments extends any[]> = {
|
|
19
|
+
[key: string]: Closure<Arguments>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export interface IOptions<Parameters extends any[]> {
|
|
23
|
+
prefix: string;
|
|
24
|
+
parameters: () => Parameters;
|
|
25
|
+
wrapper?: (name: string, output: any) => Promise<any>;
|
|
26
|
+
counter?: IPointer<number>;
|
|
27
|
+
showElapsedTime?: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function main<Arguments extends any[]>(
|
|
31
|
+
path: string,
|
|
32
|
+
options: IOptions<Arguments>,
|
|
33
|
+
): Promise<void> {
|
|
34
|
+
const command: ICommand = cli.parse();
|
|
35
|
+
await iterate(options, command, path);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function force<Arguments extends any[]>(
|
|
39
|
+
path: string,
|
|
40
|
+
options: IOptions<Arguments>,
|
|
41
|
+
): Promise<Error[]> {
|
|
42
|
+
const command: ICommand = cli.parse();
|
|
43
|
+
const exceptions: Error[] = [];
|
|
44
|
+
|
|
45
|
+
await iterate(options, command, path, exceptions);
|
|
46
|
+
return exceptions;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function iterate<Arguments extends any[]>(
|
|
50
|
+
options: IOptions<Arguments>,
|
|
51
|
+
command: ICommand,
|
|
52
|
+
path: string,
|
|
53
|
+
exceptions?: Error[],
|
|
54
|
+
): Promise<void> {
|
|
55
|
+
const directory: string[] = await fs.promises.readdir(path);
|
|
56
|
+
for (const file of directory) {
|
|
57
|
+
const current: string = `${path}/${file}`;
|
|
58
|
+
const stats: fs.Stats = await fs.promises.lstat(current);
|
|
59
|
+
|
|
60
|
+
if (stats.isDirectory() === true) {
|
|
61
|
+
await iterate(options, command, current, exceptions);
|
|
62
|
+
continue;
|
|
63
|
+
} else if (file.substr(-3) !== `.${EXTENSION}`) continue;
|
|
64
|
+
|
|
65
|
+
const external: Module<Arguments> = await import(current);
|
|
66
|
+
await execute(options, command, external, exceptions);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function execute<Arguments extends any[]>(
|
|
71
|
+
options: IOptions<Arguments>,
|
|
72
|
+
command: ICommand,
|
|
73
|
+
external: Module<Arguments>,
|
|
74
|
+
exceptions?: Error[],
|
|
75
|
+
): Promise<void> {
|
|
76
|
+
for (const key in external) {
|
|
77
|
+
if (command.exclude && key.indexOf(command.exclude) !== -1)
|
|
78
|
+
continue;
|
|
79
|
+
else if (command.include && key.indexOf(command.include) === -1)
|
|
80
|
+
continue;
|
|
81
|
+
else if (key.substr(0, options.prefix.length) !== options.prefix)
|
|
82
|
+
continue;
|
|
83
|
+
else if (external[key] instanceof Function) {
|
|
84
|
+
const closure: Closure<Arguments> = external[key];
|
|
85
|
+
const func = async () => {
|
|
86
|
+
const output = await closure(...options.parameters());
|
|
87
|
+
if (options.wrapper) await options.wrapper(key, output);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
try {
|
|
91
|
+
if (options.counter) ++options.counter.value;
|
|
92
|
+
if (options.showElapsedTime === false) {
|
|
93
|
+
await func();
|
|
94
|
+
console.log(` - ${key}`);
|
|
95
|
+
} else {
|
|
96
|
+
const time: number = await StopWatch.measure(func);
|
|
97
|
+
console.log(` - ${key}: ${time.toLocaleString()} ms`);
|
|
98
|
+
}
|
|
99
|
+
} catch (exp) {
|
|
100
|
+
if (!(exp instanceof Error)) return;
|
|
101
|
+
|
|
102
|
+
console.log(` - ${key} -> ${exp.name}`);
|
|
103
|
+
if (exceptions !== undefined) exceptions.push(exp);
|
|
104
|
+
else throw exp;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export namespace StopWatch {
|
|
2
|
+
export type Task = () => Promise<void>;
|
|
3
|
+
|
|
4
|
+
export async function measure(task: Task): Promise<number> {
|
|
5
|
+
const time: number = Date.now();
|
|
6
|
+
await task();
|
|
7
|
+
return Date.now() - time;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function trace(title: string, task: Task): Promise<void> {
|
|
11
|
+
process.stdout.write(title);
|
|
12
|
+
const time: number = await measure(task);
|
|
13
|
+
console.log(`: ${time.toLocaleString()} ms`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.1",
|
|
3
|
+
"servers": [
|
|
4
|
+
{
|
|
5
|
+
"url": "https://github.com/samchon/nestia",
|
|
6
|
+
"description": "insert your server url"
|
|
7
|
+
}
|
|
8
|
+
],
|
|
9
|
+
"info": {
|
|
10
|
+
"version": "0.1.0",
|
|
11
|
+
"title": "Generated by nestia - https://github.com/samchon/nestia"
|
|
12
|
+
},
|
|
13
|
+
"paths": {
|
|
14
|
+
"/consumers/systematic/categories": {
|
|
15
|
+
"get": {
|
|
16
|
+
"tags": [],
|
|
17
|
+
"parameters": [],
|
|
18
|
+
"responses": {
|
|
19
|
+
"200": {
|
|
20
|
+
"description": "",
|
|
21
|
+
"content": {
|
|
22
|
+
"application/json": {
|
|
23
|
+
"schema": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": {
|
|
26
|
+
"$ref": "#/components/schemas/ICategory"
|
|
27
|
+
},
|
|
28
|
+
"nullable": false
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"description": ""
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"/consumers/systematic/categories/{id}": {
|
|
38
|
+
"get": {
|
|
39
|
+
"tags": [],
|
|
40
|
+
"parameters": [
|
|
41
|
+
{
|
|
42
|
+
"name": "id",
|
|
43
|
+
"in": "path",
|
|
44
|
+
"description": "",
|
|
45
|
+
"schema": {
|
|
46
|
+
"type": "number",
|
|
47
|
+
"nullable": false
|
|
48
|
+
},
|
|
49
|
+
"required": true
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"responses": {
|
|
53
|
+
"200": {
|
|
54
|
+
"description": "",
|
|
55
|
+
"content": {
|
|
56
|
+
"application/json": {
|
|
57
|
+
"schema": {
|
|
58
|
+
"$ref": "#/components/schemas/ICategory"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"description": ""
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"/consumers/systematic/categories/{id}/invert": {
|
|
68
|
+
"get": {
|
|
69
|
+
"tags": [],
|
|
70
|
+
"parameters": [
|
|
71
|
+
{
|
|
72
|
+
"name": "id",
|
|
73
|
+
"in": "path",
|
|
74
|
+
"description": "",
|
|
75
|
+
"schema": {
|
|
76
|
+
"type": "number",
|
|
77
|
+
"nullable": false
|
|
78
|
+
},
|
|
79
|
+
"required": true
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
"responses": {
|
|
83
|
+
"200": {
|
|
84
|
+
"description": "",
|
|
85
|
+
"content": {
|
|
86
|
+
"application/json": {
|
|
87
|
+
"schema": {
|
|
88
|
+
"$ref": "#/components/schemas/ICategory.IInvert"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"description": ""
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
"components": {
|
|
99
|
+
"schemas": {
|
|
100
|
+
"ICategory": {
|
|
101
|
+
"type": "object",
|
|
102
|
+
"properties": {
|
|
103
|
+
"children": {
|
|
104
|
+
"type": "array",
|
|
105
|
+
"items": {
|
|
106
|
+
"$ref": "#/components/schemas/ICategory",
|
|
107
|
+
"description": "Children categories."
|
|
108
|
+
},
|
|
109
|
+
"nullable": false,
|
|
110
|
+
"description": "Children categories."
|
|
111
|
+
},
|
|
112
|
+
"id": {
|
|
113
|
+
"type": "number",
|
|
114
|
+
"nullable": false,
|
|
115
|
+
"description": "Primary Key."
|
|
116
|
+
},
|
|
117
|
+
"code": {
|
|
118
|
+
"type": "string",
|
|
119
|
+
"nullable": false,
|
|
120
|
+
"description": "Identifier code."
|
|
121
|
+
},
|
|
122
|
+
"name": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"nullable": false,
|
|
125
|
+
"description": "Name of the category."
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"nullable": false,
|
|
129
|
+
"required": [
|
|
130
|
+
"children",
|
|
131
|
+
"id",
|
|
132
|
+
"code",
|
|
133
|
+
"name"
|
|
134
|
+
],
|
|
135
|
+
"description": "Systematic category info.\n\nThis `ICategory` has been designed to represent a systematic classfication. Also, its\nclassification has hierarchical and recursive relationship. Therefore, its structure has\na tree shape through the {@link ICategory.children} property.\n\nIf you want to see invert structure for getting parent information repeatedly, use the\n{@link ICategory.IInvert} type instead.",
|
|
136
|
+
"jsDocTags": [
|
|
137
|
+
{
|
|
138
|
+
"name": "author",
|
|
139
|
+
"text": [
|
|
140
|
+
{
|
|
141
|
+
"text": "Jeongho Nam - https://github.com/samchon",
|
|
142
|
+
"kind": "text"
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
},
|
|
148
|
+
"ICategory.IInvert": {
|
|
149
|
+
"type": "object",
|
|
150
|
+
"properties": {
|
|
151
|
+
"parent": {
|
|
152
|
+
"$ref": "#/components/schemas/ICategory.IInvert.Nullable",
|
|
153
|
+
"description": "Parent information."
|
|
154
|
+
},
|
|
155
|
+
"id": {
|
|
156
|
+
"type": "number",
|
|
157
|
+
"nullable": false,
|
|
158
|
+
"description": "Primary Key."
|
|
159
|
+
},
|
|
160
|
+
"code": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"nullable": false,
|
|
163
|
+
"description": "Identifier code."
|
|
164
|
+
},
|
|
165
|
+
"name": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"nullable": false,
|
|
168
|
+
"description": "Name of the category."
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
"nullable": false,
|
|
172
|
+
"required": [
|
|
173
|
+
"parent",
|
|
174
|
+
"id",
|
|
175
|
+
"code",
|
|
176
|
+
"name"
|
|
177
|
+
],
|
|
178
|
+
"description": "Invert structure of the {@link ICategory}.",
|
|
179
|
+
"jsDocTags": []
|
|
180
|
+
},
|
|
181
|
+
"ICategory.IInvert.Nullable": {
|
|
182
|
+
"type": "object",
|
|
183
|
+
"properties": {
|
|
184
|
+
"parent": {
|
|
185
|
+
"$ref": "#/components/schemas/ICategory.IInvert.Nullable",
|
|
186
|
+
"description": "Parent information."
|
|
187
|
+
},
|
|
188
|
+
"id": {
|
|
189
|
+
"type": "number",
|
|
190
|
+
"nullable": false,
|
|
191
|
+
"description": "Primary Key."
|
|
192
|
+
},
|
|
193
|
+
"code": {
|
|
194
|
+
"type": "string",
|
|
195
|
+
"nullable": false,
|
|
196
|
+
"description": "Identifier code."
|
|
197
|
+
},
|
|
198
|
+
"name": {
|
|
199
|
+
"type": "string",
|
|
200
|
+
"nullable": false,
|
|
201
|
+
"description": "Name of the category."
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
"nullable": true,
|
|
205
|
+
"required": [
|
|
206
|
+
"parent",
|
|
207
|
+
"id",
|
|
208
|
+
"code",
|
|
209
|
+
"name"
|
|
210
|
+
],
|
|
211
|
+
"description": "Invert structure of the {@link ICategory}.",
|
|
212
|
+
"jsDocTags": []
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IConfiguration } from "../../src/IConfiguration";
|
|
2
|
+
|
|
3
|
+
export const NESTIA_CONFIG: IConfiguration = {
|
|
4
|
+
input: ["src/controllers"],
|
|
5
|
+
output: "src/api",
|
|
6
|
+
swagger: {
|
|
7
|
+
output: "swagger.json",
|
|
8
|
+
},
|
|
9
|
+
compilerOptions: {
|
|
10
|
+
noUnusedParameters: false,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
export default NESTIA_CONFIG;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import helper from "nestia-helper";
|
|
2
|
+
import * as nest from "@nestjs/common";
|
|
3
|
+
import { NestFactory } from "@nestjs/core";
|
|
4
|
+
import { Configuration } from "./Configuration";
|
|
5
|
+
|
|
6
|
+
export class Backend {
|
|
7
|
+
private application_?: nest.INestApplication;
|
|
8
|
+
|
|
9
|
+
public async open(): Promise<void> {
|
|
10
|
+
this.application_ = await NestFactory.create(
|
|
11
|
+
await helper.EncryptedModule.dynamic(
|
|
12
|
+
__dirname + "/controllers",
|
|
13
|
+
Configuration.ENCRYPTION_PASSWORD,
|
|
14
|
+
),
|
|
15
|
+
{ logger: false },
|
|
16
|
+
);
|
|
17
|
+
await this.application_.listen(Configuration.PORT);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async close(): Promise<void> {
|
|
21
|
+
if (this.application_ === undefined) return;
|
|
22
|
+
|
|
23
|
+
const app = this.application_;
|
|
24
|
+
delete this.application_;
|
|
25
|
+
await app.close();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HttpError } from "nestia-fetcher";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IConnection } from "nestia-fetcher";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Primitive } from "nestia-fetcher";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AesPkcs5 } from "nestia-fetcher";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Fetcher } from "nestia-fetcher";
|