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.
Files changed (225) hide show
  1. package/.eslintrc.cjs +33 -0
  2. package/.prettierignore +5 -0
  3. package/.vscode/settings.json +10 -0
  4. package/demo/encrypted/src/Backend.ts +27 -0
  5. package/demo/encrypted/src/Configuration.ts +7 -0
  6. package/demo/encrypted/src/api/HttpError.ts +1 -0
  7. package/demo/encrypted/src/api/IConnection.ts +1 -0
  8. package/demo/encrypted/src/api/Primitive.ts +1 -0
  9. package/demo/encrypted/src/api/__internal/AesPkcs5.ts +1 -0
  10. package/demo/encrypted/src/api/__internal/Fetcher.ts +1 -0
  11. package/demo/encrypted/src/api/functional/index.ts +7 -0
  12. package/demo/encrypted/src/api/functional/sellers/authenticate/index.ts +136 -0
  13. package/demo/encrypted/src/api/functional/sellers/authenticate/password/index.ts +53 -0
  14. package/demo/encrypted/src/api/functional/sellers/index.ts +7 -0
  15. package/demo/encrypted/src/api/index.ts +9 -0
  16. package/demo/encrypted/src/api/module.ts +10 -0
  17. package/demo/encrypted/src/api/structures/ISeller.ts +56 -0
  18. package/demo/encrypted/src/controllers/SellerAuthenticateController.ts +70 -0
  19. package/demo/encrypted/src/test/features/test_seller_exit.ts +18 -0
  20. package/demo/encrypted/src/test/features/test_seller_join.ts +19 -0
  21. package/demo/encrypted/src/test/features/test_seller_login.ts +16 -0
  22. package/demo/encrypted/src/test/features/test_seller_password_change.ts +18 -0
  23. package/demo/encrypted/src/test/index.ts +24 -0
  24. package/demo/encrypted/src/test/internal/DynamicImportIterator.ts +109 -0
  25. package/demo/encrypted/src/test/internal/StopWatch.ts +15 -0
  26. package/demo/encrypted/swagger.json +257 -0
  27. package/demo/encrypted/tsconfig.json +8 -0
  28. package/demo/generic/nestia.config.ts +10 -0
  29. package/demo/generic/src/Backend.ts +27 -0
  30. package/demo/generic/src/Configuration.ts +7 -0
  31. package/demo/generic/src/api/HttpError.ts +1 -0
  32. package/demo/generic/src/api/IConnection.ts +1 -0
  33. package/demo/generic/src/api/Primitive.ts +1 -0
  34. package/demo/generic/src/api/__internal/AesPkcs5.ts +1 -0
  35. package/demo/generic/src/api/__internal/Fetcher.ts +1 -0
  36. package/demo/generic/src/api/functional/consumers/index.ts +7 -0
  37. package/demo/generic/src/api/functional/consumers/sales/index.ts +8 -0
  38. package/demo/generic/src/api/functional/consumers/sales/questions/index.ts +136 -0
  39. package/demo/generic/src/api/functional/consumers/sales/reviews/index.ts +136 -0
  40. package/demo/generic/src/api/functional/index.ts +7 -0
  41. package/demo/generic/src/api/index.ts +9 -0
  42. package/demo/generic/src/api/module.ts +10 -0
  43. package/demo/generic/src/api/structures/IAttachmentFile.ts +21 -0
  44. package/demo/generic/src/api/structures/ISaleArticle.ts +79 -0
  45. package/demo/generic/src/api/structures/ISaleInquiry.ts +34 -0
  46. package/demo/generic/src/api/structures/ISaleInquiryAnswer.ts +23 -0
  47. package/demo/generic/src/api/structures/ISaleQuestion.ts +22 -0
  48. package/demo/generic/src/api/structures/ISaleReview.ts +32 -0
  49. package/demo/generic/src/controllers/ConsumerSaleQuestionsController.ts +33 -0
  50. package/demo/generic/src/controllers/ConsumerSaleReviewsController.ts +34 -0
  51. package/demo/generic/src/controllers/SaleInquiriesController.ts +87 -0
  52. package/demo/generic/src/test/features/test_question_store.ts +21 -0
  53. package/demo/generic/src/test/features/test_question_update.ts +42 -0
  54. package/demo/generic/src/test/features/test_review_store.ts +22 -0
  55. package/demo/generic/src/test/features/test_review_update.ts +44 -0
  56. package/demo/generic/src/test/index.ts +24 -0
  57. package/demo/generic/src/test/internal/DynamicImportIterator.ts +109 -0
  58. package/demo/generic/src/test/internal/StopWatch.ts +15 -0
  59. package/demo/generic/swagger.json +736 -0
  60. package/demo/generic/tsconfig.json +9 -0
  61. package/demo/multiple-paths/src/Backend.ts +27 -0
  62. package/demo/multiple-paths/src/Configuration.ts +7 -0
  63. package/demo/multiple-paths/src/api/HttpError.ts +1 -0
  64. package/demo/multiple-paths/src/api/IConnection.ts +1 -0
  65. package/demo/multiple-paths/src/api/Primitive.ts +1 -0
  66. package/demo/multiple-paths/src/api/__internal/AesPkcs5.ts +1 -0
  67. package/demo/multiple-paths/src/api/__internal/Fetcher.ts +1 -0
  68. package/demo/multiple-paths/src/api/functional/consumers/index.ts +7 -0
  69. package/demo/multiple-paths/src/api/functional/consumers/sales/articles/comments/index.ts +65 -0
  70. package/demo/multiple-paths/src/api/functional/consumers/sales/articles/index.ts +7 -0
  71. package/demo/multiple-paths/src/api/functional/consumers/sales/index.ts +7 -0
  72. package/demo/multiple-paths/src/api/functional/health/alive/index.ts +42 -0
  73. package/demo/multiple-paths/src/api/functional/health/index.ts +44 -0
  74. package/demo/multiple-paths/src/api/functional/healthy/alive/index.ts +42 -0
  75. package/demo/multiple-paths/src/api/functional/healthy/index.ts +44 -0
  76. package/demo/multiple-paths/src/api/functional/index.ts +10 -0
  77. package/demo/multiple-paths/src/api/functional/sellers/index.ts +7 -0
  78. package/demo/multiple-paths/src/api/functional/sellers/sales/articles/comments/index.ts +65 -0
  79. package/demo/multiple-paths/src/api/functional/sellers/sales/articles/index.ts +7 -0
  80. package/demo/multiple-paths/src/api/functional/sellers/sales/index.ts +7 -0
  81. package/demo/multiple-paths/src/api/index.ts +9 -0
  82. package/demo/multiple-paths/src/api/module.ts +10 -0
  83. package/demo/multiple-paths/src/api/structures/ISaleArticleComment.ts +93 -0
  84. package/demo/multiple-paths/src/controllers/HealthController.ts +7 -0
  85. package/demo/multiple-paths/src/controllers/MultipleController.ts +56 -0
  86. package/demo/multiple-paths/src/test/features/test_consumer_sale_article_comment_store.ts +21 -0
  87. package/demo/multiple-paths/src/test/features/test_health_checks.ts +10 -0
  88. package/demo/multiple-paths/src/test/features/test_seller_sale_article_store.ts +21 -0
  89. package/demo/multiple-paths/src/test/index.ts +24 -0
  90. package/demo/multiple-paths/src/test/internal/DynamicImportIterator.ts +109 -0
  91. package/demo/multiple-paths/src/test/internal/StopWatch.ts +15 -0
  92. package/demo/multiple-paths/swagger.json +338 -0
  93. package/demo/multiple-paths/tsconfig.json +3 -0
  94. package/demo/recursive/src/Backend.ts +27 -0
  95. package/demo/recursive/src/Configuration.ts +7 -0
  96. package/demo/recursive/src/api/HttpError.ts +1 -0
  97. package/demo/recursive/src/api/IConnection.ts +1 -0
  98. package/demo/recursive/src/api/Primitive.ts +1 -0
  99. package/demo/recursive/src/api/__internal/AesPkcs5.ts +1 -0
  100. package/demo/recursive/src/api/__internal/Fetcher.ts +1 -0
  101. package/demo/recursive/src/api/functional/consumers/index.ts +7 -0
  102. package/demo/recursive/src/api/functional/consumers/systematic/categories/index.ts +117 -0
  103. package/demo/recursive/src/api/functional/consumers/systematic/index.ts +7 -0
  104. package/demo/recursive/src/api/functional/index.ts +7 -0
  105. package/demo/recursive/src/api/index.ts +9 -0
  106. package/demo/recursive/src/api/module.ts +10 -0
  107. package/demo/recursive/src/api/structures/ICategory.ts +49 -0
  108. package/demo/recursive/src/consumer.categories.controller.ts +59 -0
  109. package/demo/recursive/src/test/features/test_category_at.ts +11 -0
  110. package/demo/recursive/src/test/features/test_category_invert.ts +14 -0
  111. package/demo/recursive/src/test/features/test_category_top.ts +11 -0
  112. package/demo/recursive/src/test/index.ts +24 -0
  113. package/demo/recursive/src/test/internal/DynamicImportIterator.ts +109 -0
  114. package/demo/recursive/src/test/internal/StopWatch.ts +15 -0
  115. package/demo/recursive/swagger.json +216 -0
  116. package/demo/recursive/tsconfig.json +3 -0
  117. package/demo/safe/nestia.config.ts +13 -0
  118. package/demo/safe/src/Backend.ts +27 -0
  119. package/demo/safe/src/Configuration.ts +7 -0
  120. package/demo/safe/src/api/HttpError.ts +1 -0
  121. package/demo/safe/src/api/IConnection.ts +1 -0
  122. package/demo/safe/src/api/Primitive.ts +1 -0
  123. package/demo/safe/src/api/__internal/AesPkcs5.ts +1 -0
  124. package/demo/safe/src/api/__internal/Fetcher.ts +1 -0
  125. package/demo/safe/src/api/functional/consumers/index.ts +7 -0
  126. package/demo/safe/src/api/functional/consumers/sales/articles/comments/index.ts +69 -0
  127. package/demo/safe/src/api/functional/consumers/sales/articles/index.ts +7 -0
  128. package/demo/safe/src/api/functional/consumers/sales/index.ts +7 -0
  129. package/demo/safe/src/api/functional/index.ts +7 -0
  130. package/demo/safe/src/api/index.ts +9 -0
  131. package/demo/safe/src/api/module.ts +10 -0
  132. package/demo/safe/src/api/structures/ISaleArticleComment.ts +93 -0
  133. package/demo/safe/src/controllers/ConsumerSaleArticleCommentsController.ts +63 -0
  134. package/demo/safe/src/test/features/test_comment_store.ts +23 -0
  135. package/demo/safe/src/test/index.ts +24 -0
  136. package/demo/safe/src/test/internal/DynamicImportIterator.ts +109 -0
  137. package/demo/safe/src/test/internal/StopWatch.ts +15 -0
  138. package/demo/safe/swagger.json +217 -0
  139. package/demo/safe/tsconfig.json +3 -0
  140. package/demo/tsconfig.base.json +70 -0
  141. package/demo/union/nestia.config.ts +9 -0
  142. package/demo/union/src/Backend.ts +27 -0
  143. package/demo/union/src/Configuration.ts +7 -0
  144. package/demo/union/src/api/HttpError.ts +1 -0
  145. package/demo/union/src/api/IConnection.ts +1 -0
  146. package/demo/union/src/api/Primitive.ts +1 -0
  147. package/demo/union/src/api/__internal/AesPkcs5.ts +1 -0
  148. package/demo/union/src/api/__internal/Fetcher.ts +1 -0
  149. package/demo/union/src/api/functional/consumers/index.ts +7 -0
  150. package/demo/union/src/api/functional/consumers/sales/entire_articles/index.ts +121 -0
  151. package/demo/union/src/api/functional/consumers/sales/index.ts +9 -0
  152. package/demo/union/src/api/functional/consumers/sales/questions/index.ts +57 -0
  153. package/demo/union/src/api/functional/consumers/sales/reviews/index.ts +54 -0
  154. package/demo/union/src/api/functional/index.ts +7 -0
  155. package/demo/union/src/api/index.ts +9 -0
  156. package/demo/union/src/api/module.ts +10 -0
  157. package/demo/union/src/api/structures/IAttachmentFile.ts +26 -0
  158. package/demo/union/src/api/structures/IPage.ts +80 -0
  159. package/demo/union/src/api/structures/ISaleArticle.ts +107 -0
  160. package/demo/union/src/api/structures/ISaleEntireArticle.ts +22 -0
  161. package/demo/union/src/api/structures/ISaleInquiry.ts +56 -0
  162. package/demo/union/src/api/structures/ISaleInquiryAnswer.ts +23 -0
  163. package/demo/union/src/api/structures/ISaleQuestion.ts +27 -0
  164. package/demo/union/src/api/structures/ISaleReview.ts +42 -0
  165. package/demo/union/src/controllers/ConsumerSaleEntireArticlesController.ts +109 -0
  166. package/demo/union/src/controllers/ConsumerSaleQuestionsController.ts +45 -0
  167. package/demo/union/src/controllers/ConsumerSaleReviewsController.ts +44 -0
  168. package/demo/union/src/test/features/test_sale_entire_articles_at.ts +16 -0
  169. package/demo/union/src/test/features/test_sale_entire_articles_index.ts +27 -0
  170. package/demo/union/src/test/index.ts +24 -0
  171. package/demo/union/src/test/internal/DynamicImportIterator.ts +109 -0
  172. package/demo/union/src/test/internal/StopWatch.ts +15 -0
  173. package/demo/union/swagger.json +991 -0
  174. package/demo/union/tsconfig.json +3 -0
  175. package/lib/test/TestBuilder.d.ts +4 -0
  176. package/lib/test/TestBuilder.js +60 -0
  177. package/lib/test/TestBuilder.js.map +1 -0
  178. package/lib/test/index.d.ts +1 -0
  179. package/lib/test/index.js +61 -0
  180. package/lib/test/index.js.map +1 -0
  181. package/lib/test/test.builder.executor.d.ts +1 -0
  182. package/lib/test/test.builder.executor.js +24 -0
  183. package/lib/test/test.builder.executor.js.map +1 -0
  184. package/package.json +1 -1
  185. package/prettier.config.js +7 -0
  186. package/src/IConfiguration.ts +119 -0
  187. package/src/NestiaApplication.ts +185 -0
  188. package/src/analyses/ControllerAnalyzer.ts +204 -0
  189. package/src/analyses/GenericAnalyzer.ts +53 -0
  190. package/src/analyses/ImportAnalyzer.ts +144 -0
  191. package/src/analyses/PathAnalyzer.ts +58 -0
  192. package/src/analyses/ReflectAnalyzer.ts +280 -0
  193. package/src/analyses/SourceFinder.ts +59 -0
  194. package/src/executable/internal/CompilerOptions.ts +18 -0
  195. package/src/executable/internal/NestiaCommand.ts +174 -0
  196. package/src/executable/internal/NestiaConfig.ts +36 -0
  197. package/src/executable/internal/NestiaStarter.ts +45 -0
  198. package/src/executable/internal/nestia.config.getter.ts +11 -0
  199. package/src/executable/nestia.ts +55 -0
  200. package/src/generates/FileGenerator.ts +156 -0
  201. package/src/generates/FunctionGenerator.ts +287 -0
  202. package/src/generates/SdkGenerator.ts +49 -0
  203. package/src/generates/SwaggerGenerator.ts +381 -0
  204. package/src/index.ts +2 -0
  205. package/src/module.ts +2 -0
  206. package/src/structures/IController.ts +27 -0
  207. package/src/structures/IRoute.ts +28 -0
  208. package/src/structures/ISwagger.ts +55 -0
  209. package/src/structures/ITypeTuple.ts +6 -0
  210. package/src/structures/MethodType.ts +11 -0
  211. package/src/structures/ParamCategory.ts +1 -0
  212. package/src/structures/TypeEntry.ts +22 -0
  213. package/src/test/TestBuilder.ts +49 -0
  214. package/src/test/index.ts +59 -0
  215. package/src/test/test.builder.executor.ts +11 -0
  216. package/src/utils/ArrayUtil.ts +26 -0
  217. package/src/utils/DirectoryUtil.ts +44 -0
  218. package/src/utils/ImportDictionary.ts +57 -0
  219. package/src/utils/MapUtil.ts +14 -0
  220. package/src/utils/StripEnums.ts +10 -0
  221. package/template/.eslintrc.cjs +22 -0
  222. package/template/.prettierignore +6 -0
  223. package/template/prettier.config.js +18 -0
  224. package/template/tsconfig.json +118 -0
  225. package/tsconfig.json +82 -0
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "paths": {
5
+ "@api": ["./src/api"],
6
+ "@api/*": ["./src/api/*"]
7
+ }
8
+ }
9
+ }
@@ -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,7 @@
1
+ export namespace Configuration {
2
+ export const PORT = 12345;
3
+ export const ENCRYPTION_PASSWORD = {
4
+ key: "a".repeat(32),
5
+ iv: "b".repeat(16),
6
+ };
7
+ }
@@ -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,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.consumers
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ export * as sales from "./sales";
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.consumers.sales.articles.comments
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 { ISaleArticleComment } from "./../../../../../structures/ISaleArticleComment";
11
+
12
+ /**
13
+ * Store a new comment.
14
+ *
15
+ * @param connection connection Information of the remote HTTP(s) server with headers (+encryption password)
16
+ * @param request Instance of the Express.Request
17
+ * @param section Code of the target section
18
+ * @param saleId ID of the target sale
19
+ * @param articleId ID of the target article
20
+ * @param input Content to write
21
+ * @return Newly archived comment
22
+ * @throw 400 bad request error when type of the input data is not valid
23
+ * @throw 401 unauthorized error when you've not logged in yet
24
+ * @throw 403 forbidden error when you're a seller and the sale is not yours
25
+ * @throw 404 not found error when unable to find the matched record
26
+ *
27
+ * @controller MultipleCommentsController.store()
28
+ * @path POST /consumers/:section/sales/:saleId/articles/:articleId/comments
29
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
30
+ */
31
+ export function store
32
+ (
33
+ connection: IConnection,
34
+ section: string,
35
+ saleId: number,
36
+ articleId: number,
37
+ input: Primitive<store.Input>
38
+ ): Promise<store.Output>
39
+ {
40
+ return Fetcher.fetch
41
+ (
42
+ connection,
43
+ store.ENCRYPTED,
44
+ store.METHOD,
45
+ store.path(section, saleId, articleId),
46
+ input
47
+ );
48
+ }
49
+ export namespace store
50
+ {
51
+ export type Input = Primitive<ISaleArticleComment.IStore>;
52
+ export type Output = Primitive<ISaleArticleComment>;
53
+
54
+ export const METHOD = "POST" as const;
55
+ export const PATH: string = "/consumers/:section/sales/:saleId/articles/:articleId/comments";
56
+ export const ENCRYPTED: Fetcher.IEncrypted = {
57
+ request: false,
58
+ response: false,
59
+ };
60
+
61
+ export function path(section: string, saleId: number, articleId: number): string
62
+ {
63
+ return `/consumers/${encodeURIComponent(section)}/sales/${encodeURIComponent(saleId)}/articles/${encodeURIComponent(articleId)}/comments`;
64
+ }
65
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.consumers.sales.articles
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ export * as comments from "./comments";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.consumers.sales
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ export * as articles from "./articles";
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.health.alive
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ import { Fetcher } from "nestia-fetcher";
8
+ import type { IConnection } from "nestia-fetcher";
9
+
10
+ /**
11
+ * @controller HealthController.check()
12
+ * @path GET /health/alive
13
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
14
+ */
15
+ export function check
16
+ (
17
+ connection: IConnection
18
+ ): Promise<void>
19
+ {
20
+ return Fetcher.fetch
21
+ (
22
+ connection,
23
+ check.ENCRYPTED,
24
+ check.METHOD,
25
+ check.path()
26
+ );
27
+ }
28
+ export namespace check
29
+ {
30
+
31
+ export const METHOD = "GET" as const;
32
+ export const PATH: string = "/health/alive";
33
+ export const ENCRYPTED: Fetcher.IEncrypted = {
34
+ request: false,
35
+ response: false,
36
+ };
37
+
38
+ export function path(): string
39
+ {
40
+ return `/health/alive`;
41
+ }
42
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.health
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ import { Fetcher } from "nestia-fetcher";
8
+ import type { IConnection } from "nestia-fetcher";
9
+
10
+ export * as alive from "./alive";
11
+
12
+ /**
13
+ * @controller HealthController.check()
14
+ * @path GET /health/check
15
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
16
+ */
17
+ export function check
18
+ (
19
+ connection: IConnection
20
+ ): Promise<void>
21
+ {
22
+ return Fetcher.fetch
23
+ (
24
+ connection,
25
+ check.ENCRYPTED,
26
+ check.METHOD,
27
+ check.path()
28
+ );
29
+ }
30
+ export namespace check
31
+ {
32
+
33
+ export const METHOD = "GET" as const;
34
+ export const PATH: string = "/health/check";
35
+ export const ENCRYPTED: Fetcher.IEncrypted = {
36
+ request: false,
37
+ response: false,
38
+ };
39
+
40
+ export function path(): string
41
+ {
42
+ return `/health/check`;
43
+ }
44
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.healthy.alive
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ import { Fetcher } from "nestia-fetcher";
8
+ import type { IConnection } from "nestia-fetcher";
9
+
10
+ /**
11
+ * @controller HealthController.check()
12
+ * @path GET /healthy/alive
13
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
14
+ */
15
+ export function check
16
+ (
17
+ connection: IConnection
18
+ ): Promise<void>
19
+ {
20
+ return Fetcher.fetch
21
+ (
22
+ connection,
23
+ check.ENCRYPTED,
24
+ check.METHOD,
25
+ check.path()
26
+ );
27
+ }
28
+ export namespace check
29
+ {
30
+
31
+ export const METHOD = "GET" as const;
32
+ export const PATH: string = "/healthy/alive";
33
+ export const ENCRYPTED: Fetcher.IEncrypted = {
34
+ request: false,
35
+ response: false,
36
+ };
37
+
38
+ export function path(): string
39
+ {
40
+ return `/healthy/alive`;
41
+ }
42
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.healthy
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ import { Fetcher } from "nestia-fetcher";
8
+ import type { IConnection } from "nestia-fetcher";
9
+
10
+ export * as alive from "./alive";
11
+
12
+ /**
13
+ * @controller HealthController.check()
14
+ * @path GET /healthy/check
15
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
16
+ */
17
+ export function check
18
+ (
19
+ connection: IConnection
20
+ ): Promise<void>
21
+ {
22
+ return Fetcher.fetch
23
+ (
24
+ connection,
25
+ check.ENCRYPTED,
26
+ check.METHOD,
27
+ check.path()
28
+ );
29
+ }
30
+ export namespace check
31
+ {
32
+
33
+ export const METHOD = "GET" as const;
34
+ export const PATH: string = "/healthy/check";
35
+ export const ENCRYPTED: Fetcher.IEncrypted = {
36
+ request: false,
37
+ response: false,
38
+ };
39
+
40
+ export function path(): string
41
+ {
42
+ return `/healthy/check`;
43
+ }
44
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ export * as health from "./health";
8
+ export * as healthy from "./healthy";
9
+ export * as consumers from "./consumers";
10
+ export * as sellers from "./sellers";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.sellers
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ export * as sales from "./sales";
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.sellers.sales.articles.comments
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 { ISaleArticleComment } from "./../../../../../structures/ISaleArticleComment";
11
+
12
+ /**
13
+ * Store a new comment.
14
+ *
15
+ * @param connection connection Information of the remote HTTP(s) server with headers (+encryption password)
16
+ * @param request Instance of the Express.Request
17
+ * @param section Code of the target section
18
+ * @param saleId ID of the target sale
19
+ * @param articleId ID of the target article
20
+ * @param input Content to write
21
+ * @return Newly archived comment
22
+ * @throw 400 bad request error when type of the input data is not valid
23
+ * @throw 401 unauthorized error when you've not logged in yet
24
+ * @throw 403 forbidden error when you're a seller and the sale is not yours
25
+ * @throw 404 not found error when unable to find the matched record
26
+ *
27
+ * @controller MultipleCommentsController.store()
28
+ * @path POST /sellers/:section/sales/:saleId/articles/:articleId/comments
29
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
30
+ */
31
+ export function store
32
+ (
33
+ connection: IConnection,
34
+ section: string,
35
+ saleId: number,
36
+ articleId: number,
37
+ input: Primitive<store.Input>
38
+ ): Promise<store.Output>
39
+ {
40
+ return Fetcher.fetch
41
+ (
42
+ connection,
43
+ store.ENCRYPTED,
44
+ store.METHOD,
45
+ store.path(section, saleId, articleId),
46
+ input
47
+ );
48
+ }
49
+ export namespace store
50
+ {
51
+ export type Input = Primitive<ISaleArticleComment.IStore>;
52
+ export type Output = Primitive<ISaleArticleComment>;
53
+
54
+ export const METHOD = "POST" as const;
55
+ export const PATH: string = "/sellers/:section/sales/:saleId/articles/:articleId/comments";
56
+ export const ENCRYPTED: Fetcher.IEncrypted = {
57
+ request: false,
58
+ response: false,
59
+ };
60
+
61
+ export function path(section: string, saleId: number, articleId: number): string
62
+ {
63
+ return `/sellers/${encodeURIComponent(section)}/sales/${encodeURIComponent(saleId)}/articles/${encodeURIComponent(articleId)}/comments`;
64
+ }
65
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.sellers.sales.articles
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ export * as comments from "./comments";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api.functional.sellers.sales
4
+ * @nestia Generated by Nestia - https://github.com/samchon/nestia
5
+ */
6
+ //================================================================
7
+ export * as articles from "./articles";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module api
4
+ */
5
+ //================================================================
6
+ export * from "./module";
7
+
8
+ import * as api from "./module";
9
+ export default api;
@@ -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,93 @@
1
+ /**
2
+ * Comment wrote on a sale related article.
3
+ *
4
+ * When an article of a sale has been enrolled, all of the participants like consumers and
5
+ * sellers can write a comment on that article. However, when the writer is a consumer, the
6
+ * consumer can hide its name through the annoymous option.
7
+ *
8
+ * Also, writing a reply comment for a specific comment is possible and in that case, the
9
+ * {@link ISaleArticleComment.parent_id} property would be activated.
10
+ *
11
+ * @author Jeongho Nam - https://github.com/samchon
12
+ */
13
+ export interface ISaleArticleComment {
14
+ /**
15
+ * Primary Key.
16
+ */
17
+ id: number;
18
+
19
+ /**
20
+ * Parent comment ID.
21
+ *
22
+ * Only When this comment has been written as a reply.
23
+ */
24
+ parent_id: number | null;
25
+
26
+ /**
27
+ * Type of the writer.
28
+ */
29
+ writer_type: "seller" | "consumer";
30
+
31
+ /**
32
+ * Name of the writer.
33
+ *
34
+ * When this is a type of anonymous comment, writer name would be hidden.
35
+ */
36
+ writer_name: string | null;
37
+
38
+ /**
39
+ * Contents of the comments.
40
+ *
41
+ * When the comment writer tries to modify content, it would not modify the comment
42
+ * content but would be accumulated. Therefore, all of the people can read how
43
+ * the content has been changed.
44
+ */
45
+ contents: ISaleArticleComment.IContent[];
46
+
47
+ /**
48
+ * Creation time.
49
+ */
50
+ created_at: string;
51
+ }
52
+
53
+ export namespace ISaleArticleComment {
54
+ /**
55
+ * Store info.
56
+ */
57
+ export interface IStore {
58
+ /**
59
+ * Body of the content.
60
+ */
61
+ body: string;
62
+
63
+ /**
64
+ * Extension, content type (format).
65
+ */
66
+ extension: "html" | "md" | "txt";
67
+
68
+ /**
69
+ * Whether to hide the writer name or not.
70
+ */
71
+ annonymous: boolean;
72
+ }
73
+
74
+ /**
75
+ * Content info.
76
+ */
77
+ export interface IContent {
78
+ /**
79
+ * Primary Key.
80
+ */
81
+ id: string;
82
+
83
+ /**
84
+ * Body of the content.
85
+ */
86
+ body: string;
87
+
88
+ /**
89
+ * Creation time.
90
+ */
91
+ created_at: string;
92
+ }
93
+ }
@@ -0,0 +1,7 @@
1
+ import * as nest from "@nestjs/common";
2
+
3
+ @nest.Controller(["health", "healthy"])
4
+ export class HealthController {
5
+ @nest.Get(["check", "alive"])
6
+ public check(): void {}
7
+ }
@@ -0,0 +1,56 @@
1
+ import * as express from "express";
2
+ import * as nest from "@nestjs/common";
3
+ import helper from "nestia-helper";
4
+
5
+ import { ISaleArticleComment } from "../api/structures/ISaleArticleComment";
6
+
7
+ @nest.Controller({
8
+ path: [
9
+ "consumers/:section/sales/:saleId/articles/:articleId/comments",
10
+ "sellers/:section/sales/:saleId/articles/:articleId/comments",
11
+ ],
12
+ })
13
+ export class MultipleCommentsController {
14
+ /**
15
+ * Store a new comment.
16
+ *
17
+ * @param request Instance of the Express.Request
18
+ * @param section Code of the target section
19
+ * @param saleId ID of the target sale
20
+ * @param articleId ID of the target article
21
+ * @param input Content to write
22
+ * @return Newly archived comment
23
+ *
24
+ * @throw 400 bad request error when type of the input data is not valid
25
+ * @throw 401 unauthorized error when you've not logged in yet
26
+ * @throw 403 forbidden error when you're a seller and the sale is not yours
27
+ * @throw 404 not found error when unable to find the matched record
28
+ */
29
+ @nest.Post([])
30
+ public async store(
31
+ @nest.Request() request: express.Request,
32
+ @helper.TypedParam("section", "string") section: string,
33
+ @helper.TypedParam("saleId", "number") saleId: number,
34
+ @helper.TypedParam("articleId", "number") articleId: number,
35
+ @nest.Body() input: ISaleArticleComment.IStore,
36
+ ): Promise<ISaleArticleComment> {
37
+ section;
38
+ saleId;
39
+ articleId;
40
+
41
+ return {
42
+ id: 0,
43
+ parent_id: null,
44
+ writer_type: request.path.indexOf("seller") ? "seller" : "consumer",
45
+ writer_name: input.annonymous ? null : "someone",
46
+ contents: [
47
+ {
48
+ id: "some-id",
49
+ body: input.body,
50
+ created_at: new Date().toString(),
51
+ },
52
+ ],
53
+ created_at: new Date().toString(),
54
+ };
55
+ }
56
+ }
@@ -0,0 +1,21 @@
1
+ import TSON from "typescript-json";
2
+ import api from "../../api";
3
+ import { ISaleArticleComment } from "../../api/structures/ISaleArticleComment";
4
+
5
+ export async function test_consumer_sale_article_comment_store(
6
+ connection: api.IConnection,
7
+ ): Promise<void> {
8
+ const comment: ISaleArticleComment =
9
+ await api.functional.consumers.sales.articles.comments.store(
10
+ connection,
11
+ "general",
12
+ 0,
13
+ 0,
14
+ {
15
+ body: "Some body content",
16
+ extension: "md",
17
+ annonymous: true,
18
+ },
19
+ );
20
+ TSON.assertType(comment);
21
+ }
@@ -0,0 +1,10 @@
1
+ import api from "../../api";
2
+
3
+ export async function test_health_checks(
4
+ connection: api.IConnection,
5
+ ): Promise<void> {
6
+ await api.functional.health.check(connection);
7
+ await api.functional.health.alive.check(connection);
8
+ await api.functional.healthy.check(connection);
9
+ await api.functional.healthy.alive.check(connection);
10
+ }
@@ -0,0 +1,21 @@
1
+ import TSON from "typescript-json";
2
+ import api from "../../api";
3
+ import { ISaleArticleComment } from "../../api/structures/ISaleArticleComment";
4
+
5
+ export async function test_consumer_seller_article_comment_store(
6
+ connection: api.IConnection,
7
+ ): Promise<void> {
8
+ const comment: ISaleArticleComment =
9
+ await api.functional.sellers.sales.articles.comments.store(
10
+ connection,
11
+ "general",
12
+ 0,
13
+ 0,
14
+ {
15
+ body: "Some body content",
16
+ extension: "txt",
17
+ annonymous: false,
18
+ },
19
+ );
20
+ TSON.assertType(comment);
21
+ }