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
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
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/consistent-type-definitions": "off",
|
|
18
|
+
"@typescript-eslint/no-duplicate-imports": "error",
|
|
19
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
20
|
+
"@typescript-eslint/no-empty-interface": "off",
|
|
21
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
22
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
23
|
+
"@typescript-eslint/no-namespace": "off",
|
|
24
|
+
"@typescript-eslint/no-inferrable-types": "off",
|
|
25
|
+
"@typescript-eslint/no-non-null-assertion": "off",
|
|
26
|
+
"@typescript-eslint/no-unused-vars": "off",
|
|
27
|
+
"@typescript-eslint/no-var-requires": "off",
|
|
28
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
29
|
+
"@typescript-eslint/prefer-as-const": "error",
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
};
|
|
@@ -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";
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module api.functional.sellers.authenticate
|
|
4
|
+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
5
|
+
*/
|
|
6
|
+
//================================================================
|
|
7
|
+
import { Fetcher, Primitive } from "nestia-fetcher";
|
|
8
|
+
import type { IConnection } from "nestia-fetcher";
|
|
9
|
+
|
|
10
|
+
import type { ISeller } from "./../../../structures/ISeller";
|
|
11
|
+
|
|
12
|
+
export * as password from "./password";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Join as a seller.
|
|
16
|
+
*
|
|
17
|
+
* @param connection connection Information of the remote HTTP(s) server with headers (+encryption password)
|
|
18
|
+
* @param input Information of yours
|
|
19
|
+
* @return Information of newly joined seller
|
|
20
|
+
*
|
|
21
|
+
* @controller SellerAuthenticateController.join()
|
|
22
|
+
* @path POST /sellers/authenticate/join
|
|
23
|
+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
24
|
+
*/
|
|
25
|
+
export function join
|
|
26
|
+
(
|
|
27
|
+
connection: IConnection,
|
|
28
|
+
input: Primitive<join.Input>
|
|
29
|
+
): Promise<join.Output>
|
|
30
|
+
{
|
|
31
|
+
return Fetcher.fetch
|
|
32
|
+
(
|
|
33
|
+
connection,
|
|
34
|
+
join.ENCRYPTED,
|
|
35
|
+
join.METHOD,
|
|
36
|
+
join.path(),
|
|
37
|
+
input
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
export namespace join
|
|
41
|
+
{
|
|
42
|
+
export type Input = Primitive<ISeller.IJoin>;
|
|
43
|
+
export type Output = Primitive<ISeller>;
|
|
44
|
+
|
|
45
|
+
export const METHOD = "POST" as const;
|
|
46
|
+
export const PATH: string = "/sellers/authenticate/join";
|
|
47
|
+
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
48
|
+
request: true,
|
|
49
|
+
response: true,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export function path(): string
|
|
53
|
+
{
|
|
54
|
+
return `/sellers/authenticate/join`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Log-in as a seller.
|
|
60
|
+
*
|
|
61
|
+
* @param connection connection Information of the remote HTTP(s) server with headers (+encryption password)
|
|
62
|
+
* @param input Email and password
|
|
63
|
+
* @return Information of the seller
|
|
64
|
+
*
|
|
65
|
+
* @controller SellerAuthenticateController.login()
|
|
66
|
+
* @path POST /sellers/authenticate/login
|
|
67
|
+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
68
|
+
*/
|
|
69
|
+
export function login
|
|
70
|
+
(
|
|
71
|
+
connection: IConnection,
|
|
72
|
+
input: Primitive<login.Input>
|
|
73
|
+
): Promise<login.Output>
|
|
74
|
+
{
|
|
75
|
+
return Fetcher.fetch
|
|
76
|
+
(
|
|
77
|
+
connection,
|
|
78
|
+
login.ENCRYPTED,
|
|
79
|
+
login.METHOD,
|
|
80
|
+
login.path(),
|
|
81
|
+
input
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
export namespace login
|
|
85
|
+
{
|
|
86
|
+
export type Input = Primitive<ISeller.ILogin>;
|
|
87
|
+
export type Output = Primitive<ISeller>;
|
|
88
|
+
|
|
89
|
+
export const METHOD = "POST" as const;
|
|
90
|
+
export const PATH: string = "/sellers/authenticate/login";
|
|
91
|
+
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
92
|
+
request: true,
|
|
93
|
+
response: true,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export function path(): string
|
|
97
|
+
{
|
|
98
|
+
return `/sellers/authenticate/login`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Erase the seller by itself.
|
|
104
|
+
*
|
|
105
|
+
* @controller SellerAuthenticateController.exit()
|
|
106
|
+
* @path DELETE /sellers/authenticate/exit
|
|
107
|
+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
108
|
+
*/
|
|
109
|
+
export function exit
|
|
110
|
+
(
|
|
111
|
+
connection: IConnection
|
|
112
|
+
): Promise<void>
|
|
113
|
+
{
|
|
114
|
+
return Fetcher.fetch
|
|
115
|
+
(
|
|
116
|
+
connection,
|
|
117
|
+
exit.ENCRYPTED,
|
|
118
|
+
exit.METHOD,
|
|
119
|
+
exit.path()
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
export namespace exit
|
|
123
|
+
{
|
|
124
|
+
|
|
125
|
+
export const METHOD = "DELETE" as const;
|
|
126
|
+
export const PATH: string = "/sellers/authenticate/exit";
|
|
127
|
+
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
128
|
+
request: false,
|
|
129
|
+
response: false,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export function path(): string
|
|
133
|
+
{
|
|
134
|
+
return `/sellers/authenticate/exit`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @packageDocumentation
|
|
3
|
+
* @module api.functional.sellers.authenticate.password
|
|
4
|
+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
5
|
+
*/
|
|
6
|
+
//================================================================
|
|
7
|
+
import { Fetcher, Primitive } from "nestia-fetcher";
|
|
8
|
+
import type { IConnection } from "nestia-fetcher";
|
|
9
|
+
|
|
10
|
+
import type { ISeller } from "./../../../../structures/ISeller";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Change password.
|
|
14
|
+
*
|
|
15
|
+
* @param connection connection Information of the remote HTTP(s) server with headers (+encryption password)
|
|
16
|
+
* @param input Old and new passwords
|
|
17
|
+
* @return Empty object
|
|
18
|
+
*
|
|
19
|
+
* @controller SellerAuthenticateController.change()
|
|
20
|
+
* @path PATCH /sellers/authenticate/password/change
|
|
21
|
+
* @nestia Generated by Nestia - https://github.com/samchon/nestia
|
|
22
|
+
*/
|
|
23
|
+
export function change
|
|
24
|
+
(
|
|
25
|
+
connection: IConnection,
|
|
26
|
+
input: Primitive<change.Input>
|
|
27
|
+
): Promise<void>
|
|
28
|
+
{
|
|
29
|
+
return Fetcher.fetch
|
|
30
|
+
(
|
|
31
|
+
connection,
|
|
32
|
+
change.ENCRYPTED,
|
|
33
|
+
change.METHOD,
|
|
34
|
+
change.path(),
|
|
35
|
+
input
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
export namespace change
|
|
39
|
+
{
|
|
40
|
+
export type Input = Primitive<ISeller.IChangePassword>;
|
|
41
|
+
|
|
42
|
+
export const METHOD = "PATCH" as const;
|
|
43
|
+
export const PATH: string = "/sellers/authenticate/password/change";
|
|
44
|
+
export const ENCRYPTED: Fetcher.IEncrypted = {
|
|
45
|
+
request: true,
|
|
46
|
+
response: false,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export function path(): string
|
|
50
|
+
{
|
|
51
|
+
return `/sellers/authenticate/password/change`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -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,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seller information.
|
|
3
|
+
*
|
|
4
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
5
|
+
*/
|
|
6
|
+
export interface ISeller {
|
|
7
|
+
/**
|
|
8
|
+
* Primary key.
|
|
9
|
+
*/
|
|
10
|
+
id: number;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Email address.
|
|
14
|
+
*/
|
|
15
|
+
email: string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Name of the seller.
|
|
19
|
+
*/
|
|
20
|
+
name: string;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Mobile number of the seller.
|
|
24
|
+
*/
|
|
25
|
+
mobile: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Belonged company name.
|
|
29
|
+
*/
|
|
30
|
+
company: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Joined time.
|
|
34
|
+
*/
|
|
35
|
+
created_at: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export namespace ISeller {
|
|
39
|
+
export interface ILogin {
|
|
40
|
+
email: string;
|
|
41
|
+
password: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IJoin {
|
|
45
|
+
email: string;
|
|
46
|
+
password: string;
|
|
47
|
+
name: string;
|
|
48
|
+
mobile: string;
|
|
49
|
+
company: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface IChangePassword {
|
|
53
|
+
old_password: string;
|
|
54
|
+
new_password: string;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type express from "express";
|
|
2
|
+
import * as nest from "@nestjs/common";
|
|
3
|
+
import helper from "nestia-helper";
|
|
4
|
+
|
|
5
|
+
import { ISeller } from "../api/structures/ISeller";
|
|
6
|
+
|
|
7
|
+
@nest.Controller("sellers/authenticate")
|
|
8
|
+
export class SellerAuthenticateController {
|
|
9
|
+
/**
|
|
10
|
+
* Join as a seller.
|
|
11
|
+
*
|
|
12
|
+
* @param input Information of yours
|
|
13
|
+
* @return Information of newly joined seller
|
|
14
|
+
*/
|
|
15
|
+
@helper.EncryptedRoute.Post("join")
|
|
16
|
+
public async join(
|
|
17
|
+
@helper.EncryptedBody() input: ISeller.IJoin,
|
|
18
|
+
): Promise<ISeller> {
|
|
19
|
+
return {
|
|
20
|
+
id: 0,
|
|
21
|
+
email: input.email,
|
|
22
|
+
name: input.name,
|
|
23
|
+
mobile: input.mobile,
|
|
24
|
+
company: input.company,
|
|
25
|
+
created_at: new Date().toString(),
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Log-in as a seller.
|
|
31
|
+
*
|
|
32
|
+
* @param input Email and password
|
|
33
|
+
* @return Information of the seller
|
|
34
|
+
*/
|
|
35
|
+
@helper.EncryptedRoute.Post("login")
|
|
36
|
+
public async login(
|
|
37
|
+
@helper.EncryptedBody() input: ISeller.ILogin,
|
|
38
|
+
): Promise<ISeller> {
|
|
39
|
+
return {
|
|
40
|
+
id: 0,
|
|
41
|
+
email: input.email,
|
|
42
|
+
mobile: "01012345678",
|
|
43
|
+
name: "John Doe",
|
|
44
|
+
company: "ABC Company",
|
|
45
|
+
created_at: new Date().toString(),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Change password.
|
|
51
|
+
*
|
|
52
|
+
* @param input Old and new passwords
|
|
53
|
+
* @return Empty object
|
|
54
|
+
*/
|
|
55
|
+
@nest.Patch("password/change")
|
|
56
|
+
public async change(
|
|
57
|
+
@nest.Request() _httpReq: express.Request,
|
|
58
|
+
@helper.EncryptedBody() input: ISeller.IChangePassword,
|
|
59
|
+
): Promise<void> {
|
|
60
|
+
input;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Erase the seller by itself.
|
|
65
|
+
*/
|
|
66
|
+
@nest.Delete("exit")
|
|
67
|
+
public async exit(
|
|
68
|
+
@nest.Request() _httpReq: express.Request,
|
|
69
|
+
): Promise<void> {}
|
|
70
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import TSON from "typescript-json";
|
|
2
|
+
import api from "../../api";
|
|
3
|
+
import { ISeller } from "../../api/structures/ISeller";
|
|
4
|
+
|
|
5
|
+
export async function test_seller_exit(
|
|
6
|
+
connection: api.IConnection,
|
|
7
|
+
): Promise<void> {
|
|
8
|
+
const seller: ISeller = await api.functional.sellers.authenticate.login(
|
|
9
|
+
connection,
|
|
10
|
+
{
|
|
11
|
+
email: "someone@someone.com",
|
|
12
|
+
password: "qweqwe123!",
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
TSON.assertType(seller);
|
|
16
|
+
|
|
17
|
+
await api.functional.sellers.authenticate.exit(connection);
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import TSON from "typescript-json";
|
|
2
|
+
import api from "../../api";
|
|
3
|
+
import { ISeller } from "../../api/structures/ISeller";
|
|
4
|
+
|
|
5
|
+
export async function test_seller_join(
|
|
6
|
+
connection: api.IConnection,
|
|
7
|
+
): Promise<void> {
|
|
8
|
+
const seller: ISeller = await api.functional.sellers.authenticate.join(
|
|
9
|
+
connection,
|
|
10
|
+
{
|
|
11
|
+
email: "someone@someone.com",
|
|
12
|
+
name: "Someone",
|
|
13
|
+
mobile: "01012345678",
|
|
14
|
+
company: "Some Company",
|
|
15
|
+
password: "qweqwe123!",
|
|
16
|
+
},
|
|
17
|
+
);
|
|
18
|
+
TSON.assertType(seller);
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import TSON from "typescript-json";
|
|
2
|
+
import api from "../../api";
|
|
3
|
+
import { ISeller } from "../../api/structures/ISeller";
|
|
4
|
+
|
|
5
|
+
export async function test_seller_login(
|
|
6
|
+
connection: api.IConnection,
|
|
7
|
+
): Promise<void> {
|
|
8
|
+
const seller: ISeller = await api.functional.sellers.authenticate.login(
|
|
9
|
+
connection,
|
|
10
|
+
{
|
|
11
|
+
email: "someone@someone.com",
|
|
12
|
+
password: "qweqwe123!",
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
TSON.assertType(seller);
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import TSON from "typescript-json";
|
|
2
|
+
import api from "../../api";
|
|
3
|
+
import { ISeller } from "../../api/structures/ISeller";
|
|
4
|
+
|
|
5
|
+
export async function test_seller_password_change(
|
|
6
|
+
connection: api.IConnection,
|
|
7
|
+
): Promise<void> {
|
|
8
|
+
const seller: ISeller = await api.functional.sellers.authenticate.login(
|
|
9
|
+
connection,
|
|
10
|
+
{
|
|
11
|
+
email: "someone@someone.com",
|
|
12
|
+
password: "qweqwe123!",
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
TSON.assertType(seller);
|
|
16
|
+
|
|
17
|
+
await api.functional.sellers.authenticate.exit(connection);
|
|
18
|
+
}
|
|
@@ -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
|
+
}
|