nestia 2.1.0-dev.20220504 → 2.1.0
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/.github/ISSUE_TEMPLATE/BUG_REPORT.md +42 -0
- package/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +13 -0
- package/.github/ISSUE_TEMPLATE/QUESTION.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- package/CODE_OF_CONDUCT.md +133 -0
- package/CONTRIBUTING.md +72 -0
- package/README.md +271 -9
- package/lib/analyses/ControllerAnalyzer.d.ts.map +1 -1
- package/lib/analyses/ControllerAnalyzer.js +3 -1
- package/lib/factories/CommentFactory.d.ts +5 -0
- package/lib/factories/CommentFactory.d.ts.map +1 -0
- package/lib/factories/CommentFactory.js +14 -0
- package/lib/factories/MetadataCollection.d.ts +14 -0
- package/lib/factories/MetadataCollection.d.ts.map +1 -0
- package/lib/factories/MetadataCollection.js +83 -0
- package/lib/factories/MetadataFactory.d.ts +8 -0
- package/lib/factories/MetadataFactory.d.ts.map +1 -0
- package/lib/factories/MetadataFactory.js +255 -0
- package/lib/factories/SchemaFactory.d.ts +9 -0
- package/lib/factories/SchemaFactory.d.ts.map +1 -0
- package/lib/factories/SchemaFactory.js +179 -0
- package/lib/factories/TypeFactry.d.ts +7 -0
- package/lib/factories/TypeFactry.d.ts.map +1 -0
- package/lib/factories/TypeFactry.js +76 -0
- package/lib/generates/SwaggerGenerator.d.ts.map +1 -1
- package/lib/generates/SwaggerGenerator.js +82 -23
- package/lib/structures/IMetadata.d.ts +21 -0
- package/lib/structures/IMetadata.d.ts.map +1 -0
- package/lib/structures/IMetadata.js +3 -0
- package/lib/structures/ISwagger.d.ts +3 -1
- package/lib/structures/ISwagger.d.ts.map +1 -1
- package/lib/structures/TypeEntry.d.ts +10 -0
- package/lib/structures/TypeEntry.d.ts.map +1 -0
- package/lib/structures/TypeEntry.js +22 -0
- package/package.json +4 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Bug Report
|
|
8
|
+
Note that, the bug you're reporting may have registered in the [issues](https://github.com/samchon/nestia/search?type=issues) by another user. Even the bug you're reporting may have been fixed in the `@next` version. In such reasons, I recommend you to check the old [issues](https://github.com/samchon/nestia/search?type=issues) and reproduct your code with the `@next` version before publishing the bug reporting issue.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
`npm install --save-dev nestia@next`
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
When the same error occurs even in the `@next` version, then please fill the below template:
|
|
15
|
+
|
|
16
|
+
### Summary
|
|
17
|
+
Write a short summary of the bug in here.
|
|
18
|
+
|
|
19
|
+
- **SDK Version**: 2.1.0-dev.20220505
|
|
20
|
+
- **Expected behavior**:
|
|
21
|
+
- **Actual behavior**:
|
|
22
|
+
|
|
23
|
+
Write detailed description in here.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Code occuring the bug
|
|
28
|
+
```typescript
|
|
29
|
+
/* Demonstration code occuring the bug you're reporting */
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Write the demonstration code occuring the bug you're reporting.
|
|
33
|
+
|
|
34
|
+
However, as the `nestia` is not a typical library who being used by the `import` statement but a executable program generating the SDK (Software Development Kit), it would be difficult to describe the bug with only the demonstration code.
|
|
35
|
+
|
|
36
|
+
In that case, you'd better to make a demonstration project occuring the bug to report. After the demonstration repository composition, fill the below `bash` script section. Of course, if you can describe the bug clearly, without the demonstration project construction, just skip it. Creating the demonstration repository is not essential.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
git clone https://github.com/someone/nestia-bug-report-xxx
|
|
40
|
+
cd nestia-bug-report-xxx
|
|
41
|
+
npx nestia sdk
|
|
42
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Feature Request
|
|
8
|
+
Thanks for your suggestion. Feel free to just state your idea. Writing the issue, it would better to filling the below items:
|
|
9
|
+
|
|
10
|
+
- A description of the problem you're trying to solve.
|
|
11
|
+
- An overview of the suggested solution.
|
|
12
|
+
- Examples of how the suggestion whould work in various places.
|
|
13
|
+
- Code examples showing the expected behavior.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Question
|
|
3
|
+
about: What do you want to know?
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Question
|
|
8
|
+
I always welcome any questions about this backend proejct. However, half of questions can be solved by traveling [README.md](https://github.com/samchon/nestia) or old [issues](https://github.com/samchon/nestia/search?type=issues). Therefore, I recommend you to visit them before. If you have a question that has not been treated and you're extremely urgently, just contact me.
|
|
9
|
+
|
|
10
|
+
- E-mail: samchon.github@gmail.com
|
|
11
|
+
- Mobile: 82-10-3627-0016
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Before submitting a Pull Request, please test your code.
|
|
2
|
+
|
|
3
|
+
If you created a new created a new feature, then create the unit test function, too.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
# COMPILE THE BACKEND SERVER
|
|
7
|
+
npm run build
|
|
8
|
+
|
|
9
|
+
# RUN THE TEST AUTOMATION PROGRAM
|
|
10
|
+
npm run test
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Learn more about the [CONTRIBUTING](CONTRIBUTING.md)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
|
|
2
|
+
# Contributor Covenant Code of Conduct
|
|
3
|
+
|
|
4
|
+
## Our Pledge
|
|
5
|
+
|
|
6
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
7
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
9
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
10
|
+
nationality, personal appearance, race, caste, color, religion, or sexual identity
|
|
11
|
+
and orientation.
|
|
12
|
+
|
|
13
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
14
|
+
diverse, inclusive, and healthy community.
|
|
15
|
+
|
|
16
|
+
## Our Standards
|
|
17
|
+
|
|
18
|
+
Examples of behavior that contributes to a positive environment for our
|
|
19
|
+
community include:
|
|
20
|
+
|
|
21
|
+
* Demonstrating empathy and kindness toward other people
|
|
22
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
23
|
+
* Giving and gracefully accepting constructive feedback
|
|
24
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
25
|
+
and learning from the experience
|
|
26
|
+
* Focusing on what is best not just for us as individuals, but for the
|
|
27
|
+
overall community
|
|
28
|
+
|
|
29
|
+
Examples of unacceptable behavior include:
|
|
30
|
+
|
|
31
|
+
* The use of sexualized language or imagery, and sexual attention or
|
|
32
|
+
advances of any kind
|
|
33
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
34
|
+
* Public or private harassment
|
|
35
|
+
* Publishing others' private information, such as a physical or email
|
|
36
|
+
address, without their explicit permission
|
|
37
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
38
|
+
professional setting
|
|
39
|
+
|
|
40
|
+
## Enforcement Responsibilities
|
|
41
|
+
|
|
42
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
43
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
44
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
45
|
+
or harmful.
|
|
46
|
+
|
|
47
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
48
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
49
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
50
|
+
decisions when appropriate.
|
|
51
|
+
|
|
52
|
+
## Scope
|
|
53
|
+
|
|
54
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
55
|
+
an individual is officially representing the community in public spaces.
|
|
56
|
+
Examples of representing our community include using an official e-mail address,
|
|
57
|
+
posting via an official social media account, or acting as an appointed
|
|
58
|
+
representative at an online or offline event.
|
|
59
|
+
|
|
60
|
+
## Enforcement
|
|
61
|
+
|
|
62
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
63
|
+
reported to the community leaders responsible for enforcement at
|
|
64
|
+
[INSERT CONTACT METHOD].
|
|
65
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
66
|
+
|
|
67
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
68
|
+
reporter of any incident.
|
|
69
|
+
|
|
70
|
+
## Enforcement Guidelines
|
|
71
|
+
|
|
72
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
73
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
74
|
+
|
|
75
|
+
### 1. Correction
|
|
76
|
+
|
|
77
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
78
|
+
unprofessional or unwelcome in the community.
|
|
79
|
+
|
|
80
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
81
|
+
clarity around the nature of the violation and an explanation of why the
|
|
82
|
+
behavior was inappropriate. A public apology may be requested.
|
|
83
|
+
|
|
84
|
+
### 2. Warning
|
|
85
|
+
|
|
86
|
+
**Community Impact**: A violation through a single incident or series
|
|
87
|
+
of actions.
|
|
88
|
+
|
|
89
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
90
|
+
interaction with the people involved, including unsolicited interaction with
|
|
91
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
92
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
93
|
+
like social media. Violating these terms may lead to a temporary or
|
|
94
|
+
permanent ban.
|
|
95
|
+
|
|
96
|
+
### 3. Temporary Ban
|
|
97
|
+
|
|
98
|
+
**Community Impact**: A serious violation of community standards, including
|
|
99
|
+
sustained inappropriate behavior.
|
|
100
|
+
|
|
101
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
102
|
+
communication with the community for a specified period of time. No public or
|
|
103
|
+
private interaction with the people involved, including unsolicited interaction
|
|
104
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
105
|
+
Violating these terms may lead to a permanent ban.
|
|
106
|
+
|
|
107
|
+
### 4. Permanent Ban
|
|
108
|
+
|
|
109
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
110
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
111
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
112
|
+
|
|
113
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
|
114
|
+
the community.
|
|
115
|
+
|
|
116
|
+
## Attribution
|
|
117
|
+
|
|
118
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
119
|
+
version 2.0, available at
|
|
120
|
+
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
|
|
121
|
+
|
|
122
|
+
Community Impact Guidelines were inspired by
|
|
123
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
124
|
+
|
|
125
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
126
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
|
127
|
+
at [https://www.contributor-covenant.org/translations][translations].
|
|
128
|
+
|
|
129
|
+
[homepage]: https://www.contributor-covenant.org
|
|
130
|
+
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
|
131
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
132
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
133
|
+
[translations]: https://www.contributor-covenant.org/translations
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Contribution Guide
|
|
2
|
+
## To Publish an issue
|
|
3
|
+
Thanks for your advise. Before publishing an issue, please check some components.
|
|
4
|
+
|
|
5
|
+
### 1. Search for duplicates
|
|
6
|
+
Before publishing an issue, please check whether the duplicated issue exists or not.
|
|
7
|
+
|
|
8
|
+
- [Ordinary Issues](https://github.com/samchon/nestia/issues)
|
|
9
|
+
|
|
10
|
+
### 2. Did you find a bug?
|
|
11
|
+
When you reporting a bug, then please write about those items:
|
|
12
|
+
|
|
13
|
+
- What version you're using
|
|
14
|
+
- If possible, give me an isolated way to reproduce the behavior.
|
|
15
|
+
- The behavior your expect to see, and the actual behavior.
|
|
16
|
+
|
|
17
|
+
### 3. Do you have a suggestion?
|
|
18
|
+
I always welcome your suggestion. When you publishing a suggestion, then please write such items:
|
|
19
|
+
|
|
20
|
+
- A description of the problem you're trying to solve.
|
|
21
|
+
- An overview of the suggested solution.
|
|
22
|
+
- Examples of how the suggestion whould work in various places.
|
|
23
|
+
- Code examples showing the expected behavior.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Contributing Code
|
|
29
|
+
### Test your code
|
|
30
|
+
Before sending a pull request, please test your new code. You type the command `npm run build &&& npm run test`, then compiling your code and test-automation will be all processed.
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# COMPILE
|
|
34
|
+
npm run build
|
|
35
|
+
|
|
36
|
+
# DO TEST
|
|
37
|
+
npm run test
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
If you succeeded to compile, but failed to pass the test-automation, then *debug* the test-automation module. I've configured the `.vscode/launch.json`. You just run the `VSCode` and click the `Start Debugging` button or press `F5` key. By the *debugging*, find the reason why the *test* is failed and fix it.
|
|
41
|
+
|
|
42
|
+
### Adding a Test
|
|
43
|
+
As this `nestia` is not a typical library who being used by the `import` statement but a executable program generating the SDK (Software Development Kit), adding a test means that adding a demonstration project.
|
|
44
|
+
|
|
45
|
+
I know that adding a demonstration project is much difficult than adding a test function, but there's no way if newly contributed code requires a new type of testing tool. Looking at the [src/test/demonstratios](src/test/demonstrations) directory and traveling the demonstration projects, create a new demonstration project following their structures and styles.
|
|
46
|
+
|
|
47
|
+
Of course, if your contribution code does not require a test new project, don't mind this.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Sending a Pull Request
|
|
53
|
+
Thanks for your contributing. Before sending a pull request to me, please check those components.
|
|
54
|
+
|
|
55
|
+
### 1. Include enough descriptions
|
|
56
|
+
When you send a pull request, please include a description, of what your change intends to do, on the content. Title, make it clear and simple such below:
|
|
57
|
+
|
|
58
|
+
- Refactor features
|
|
59
|
+
- Fix #17
|
|
60
|
+
- Add tests for #28
|
|
61
|
+
|
|
62
|
+
### 2. Include adequate tests
|
|
63
|
+
As I've mentioned in the `Contributing Code` section, your PR should pass the test-automation module. Your PR includes *new features* that have not being handled in the ordinary test-automation module, then also update *add the testing unit* please.
|
|
64
|
+
|
|
65
|
+
If there're some specific reasons that could not pass the test-automation (not error but *intended*), then please update the ordinary test-automation module or write the reasons on your PR content and *const me update the test-automation module*.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
## References
|
|
71
|
+
I've referenced contribution guidance of the TypeScript.
|
|
72
|
+
- https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md
|
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Nestia
|
|
2
|
-
Automatic SDK generator for the NestJS.
|
|
2
|
+
Automatic `SDK` and `swagger.json` generator for the NestJS.
|
|
3
3
|
|
|
4
4
|
[](https://github.com/samchon/nestia/blob/master/LICENSE)
|
|
5
5
|
[](https://www.npmjs.com/package/nestia)
|
|
@@ -20,11 +20,17 @@ npx nestia sdk "src/**/*.controller.ts" --out "src/api"
|
|
|
20
20
|
npx nestia swagger "src/controller" -- out "swagger.json"
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
Don't write any `swagger` comment. Just
|
|
23
|
+
Don't write any `swagger` comment and DTO decorator. Just run the **Nestia** up.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
- No swagger comment/decorator
|
|
26
|
+
- No DTO comment/decorator
|
|
27
|
+
- Only pure NestJS code is required
|
|
26
28
|
|
|
27
|
-
|
|
29
|
+
When you're developing a backend server using the `NestJS`, you don't need any extra dedication, for delivering the Rest API to the client developers, like writing the `swagger` comments or DTO decorators.
|
|
30
|
+
|
|
31
|
+
You just run this **Nestia** up, then **Nestia** would generate the SDK automatically, by analyzing your controller classes in the compliation and runtime level. With the automatically generated SDK through this **Nestia**, client developer also does not need any extra work, like reading `swagger` and writing the duplicated interaction code. Client developer only needs to import the SDK and calls matched function with the `await` symbol.
|
|
32
|
+
|
|
33
|
+
> Even generating the `swagger.json` without any swagger comment and DTO decorator is also possible. When generating the `swagger.json`, no DTO comment and decorator is required, either. Use only the pure interface definitions.
|
|
28
34
|
|
|
29
35
|
```typescript
|
|
30
36
|
import api from "@samchon/bbs-api";
|
|
@@ -81,12 +87,28 @@ Just type the `nestia sdk <input> --out <output>` command in the console. When t
|
|
|
81
87
|
|
|
82
88
|
Also, when generating a SDK using the cli options, `compilerOptions` would follow the `tsconfig.json`, that is configured for the backend server. If no `tsconfig.json` file exists in your project, the configuration would be default option (`ES5` with `strict` mode). If you want to use different `compilerOptions` with the `tsconfig.json`, you should configure the [nestia.config.ts](#nestiaconfigts).
|
|
83
89
|
|
|
90
|
+
### Swagger generation
|
|
91
|
+
```bash
|
|
92
|
+
npx nestia <source_controller_of_directory> --out <output_path>
|
|
93
|
+
|
|
94
|
+
npx nestia swagger "src/**/*.controller.ts" --out "./"
|
|
95
|
+
npx nestia swagger "src/controllers" --out "./swagger.json"
|
|
96
|
+
npx nestia swagger "src/consumers" "src/sellers" --out "actors.json"
|
|
97
|
+
npx nestia swagger "src/controllers" --exclude "src/**/Fake*.ts" -out "./"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The **Nestia** even supports the `swagger.json` generation and it's also extermely easy.
|
|
101
|
+
|
|
102
|
+
Jsut type the `nestia swagger <input> --out <output>` command in the console. When there're multiple source directories containing the NestJS controller classes, type all of them separating by a `space` word. If you want to exclude some directories or files from the `swagger.json` generation, the `--exclude` option would be useful.
|
|
103
|
+
|
|
104
|
+
Also, when generating a SDK using the cli options, `compilerOptions` would follow the `tsconfig.json`, that is configured for the backend server. If no `tsconfig.json` file exists in your project, the configuration would be default option (`ES5` with `strict` mode). If you want to use different `compilerOptions` with the `tsconfig.json`, you should configure the [nestia.config.ts](#nestiaconfigts).
|
|
105
|
+
|
|
84
106
|
### Dependencies
|
|
85
107
|
```bash
|
|
86
108
|
npx nestia install
|
|
87
109
|
```
|
|
88
110
|
|
|
89
|
-
SDK library generated by the **Nestia** requires the [nestia-fetcher](https://github.com/samchon/nestia-fetcher)
|
|
111
|
+
SDK library generated by the **Nestia** requires the [nestia-fetcher](https://github.com/samchon/nestia-fetcher) module. Also, the [typescript-is](https://github.com/woutervh-/typescript-is) and [typescript-json](https://github.com/samchon/typescript-json) modules can be required following your [nestia.config.ts](#nestiaconfigts) options.
|
|
90
112
|
|
|
91
113
|
The `npx nestia install` command installs those dependencies with `package.json` configuration.
|
|
92
114
|
|
|
@@ -94,8 +116,9 @@ The `npx nestia install` command installs those dependencies with `package.json`
|
|
|
94
116
|
{
|
|
95
117
|
"name": "payments-server-api",
|
|
96
118
|
"dependencies": {
|
|
97
|
-
"nestia-fetcher": "^2.0.
|
|
98
|
-
"typescript-is": "^0.19.0"
|
|
119
|
+
"nestia-fetcher": "^2.0.1",
|
|
120
|
+
"typescript-is": "^0.19.0",
|
|
121
|
+
"typescript-json": "^2.0.9"
|
|
99
122
|
}
|
|
100
123
|
}
|
|
101
124
|
```
|
|
@@ -246,8 +269,8 @@ For your deep understanding about this directory structure with this **Nestia**,
|
|
|
246
269
|
To demonstrate which SDK codes would be generated by this **Nestia**:
|
|
247
270
|
|
|
248
271
|
- Representative files
|
|
272
|
+
- [DTO interface used in the RestAPI](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/default/src/api/structures/sales/articles/ISaleArticle.ts)
|
|
249
273
|
- [Controllers of the NestJS](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/default/src/controllers/base/SaleCommentsController.ts)
|
|
250
|
-
- [Structures used in the RestAPI](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/default/src/api/structures/sales/articles/ISaleArticle.ts)
|
|
251
274
|
- [SDK generated by this **Nestia**](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/default/src/api/functional/consumers/sales/reviews/index.ts)
|
|
252
275
|
- Demonstration Projects
|
|
253
276
|
- [absolute](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/absolute): Absolute path with the `baseUrl` option
|
|
@@ -260,6 +283,77 @@ To demonstrate which SDK codes would be generated by this **Nestia**:
|
|
|
260
283
|
- [reference](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/reference): Configured input files as `src/**/*.controller.ts`
|
|
261
284
|
- [tsconfig.json](https://github.com/samchon/nestia/tree/master/src/test/demonstrations/tsconfig.json): Special configuration through the `tsconfig.json`
|
|
262
285
|
|
|
286
|
+
### DTO
|
|
287
|
+
As you can see from the below code, the **Nestia** can use the interface directory.
|
|
288
|
+
|
|
289
|
+
You dont' need to define any extra comment or decorator function to make the DTO (Data Transfer Object). Just define the DTO as a pure interface structure, then **Nestia** will do everything instead of you.
|
|
290
|
+
|
|
291
|
+
If you're afraiding because your type is union or intersection, I can say that it does not matter. Even when generic or conditional type comes, it does not matter. Just enjoy the pure TypeScript type.
|
|
292
|
+
|
|
293
|
+
```typescript
|
|
294
|
+
/**
|
|
295
|
+
* Comment wrote on an article.
|
|
296
|
+
*
|
|
297
|
+
* @author Jeongho Nam - https://github.com/samchon
|
|
298
|
+
*/
|
|
299
|
+
export interface ISaleComment
|
|
300
|
+
{
|
|
301
|
+
/**
|
|
302
|
+
* Primary Key.
|
|
303
|
+
*/
|
|
304
|
+
id: number;
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Type of the writer.
|
|
308
|
+
*/
|
|
309
|
+
writer_type: "seller" | "consumer";
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Name of the writer.
|
|
313
|
+
*/
|
|
314
|
+
writer_name: string;
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Contents of the comments.
|
|
318
|
+
*
|
|
319
|
+
* When the comment writer tries to modify content, it would not modify the comment
|
|
320
|
+
* content but would be accumulated. Therefore, all of the people can read how
|
|
321
|
+
* the content has been changed.
|
|
322
|
+
*/
|
|
323
|
+
contents: ISaleComment.IContent[];
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* Creation time.
|
|
327
|
+
*/
|
|
328
|
+
created_at: string;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export namespace ISaleComment
|
|
332
|
+
{
|
|
333
|
+
/**
|
|
334
|
+
* Store info.
|
|
335
|
+
*/
|
|
336
|
+
export interface IStore
|
|
337
|
+
{
|
|
338
|
+
/**
|
|
339
|
+
* Body of the content.
|
|
340
|
+
*/
|
|
341
|
+
body: string;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Content info.
|
|
346
|
+
*/
|
|
347
|
+
export interface IContent extends IStore
|
|
348
|
+
{
|
|
349
|
+
/**
|
|
350
|
+
* Creation time.
|
|
351
|
+
*/
|
|
352
|
+
created_at: string;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
```
|
|
356
|
+
|
|
263
357
|
### Controller
|
|
264
358
|
If you've decided to adapt this **Nestia** and you want to generate the SDK directly, you don't need any extra work. Just keep you controller class down and do noting. The only one exceptional case that you need an extra dedication is, when you want to explain about the API function to the client developers through the comments.
|
|
265
359
|
|
|
@@ -348,6 +442,174 @@ export namespace store
|
|
|
348
442
|
}
|
|
349
443
|
```
|
|
350
444
|
|
|
445
|
+
### `swagger.json`
|
|
446
|
+
Even the `swagger.json` generation does not require any swagger comment and DTO decorator.
|
|
447
|
+
|
|
448
|
+
The **Nestia** will generate the perfect `swagger.json` automatically, by analyzing your source code (DTO interface and controller class) in the compilation and runtime level. Furthermore, your descriptive comments would be automatically assigned into the adequate `description` property in the `swagger.json`.
|
|
449
|
+
|
|
450
|
+
```json
|
|
451
|
+
{
|
|
452
|
+
"paths": {
|
|
453
|
+
"/consumers/{section}/sales/{saleId}/comments/{articleId}": {
|
|
454
|
+
"post": {
|
|
455
|
+
"tags": [],
|
|
456
|
+
"parameters": [
|
|
457
|
+
{
|
|
458
|
+
"name": "section",
|
|
459
|
+
"in": "path",
|
|
460
|
+
"description": "Code of the target section",
|
|
461
|
+
"schema": {
|
|
462
|
+
"type": "string",
|
|
463
|
+
"nullable": false
|
|
464
|
+
},
|
|
465
|
+
"required": true
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
"name": "saleId",
|
|
469
|
+
"in": "path",
|
|
470
|
+
"description": "ID of the target sale",
|
|
471
|
+
"schema": {
|
|
472
|
+
"type": "number",
|
|
473
|
+
"nullable": false
|
|
474
|
+
},
|
|
475
|
+
"required": true
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
"name": "articleId",
|
|
479
|
+
"in": "path",
|
|
480
|
+
"description": "ID of the target article",
|
|
481
|
+
"schema": {
|
|
482
|
+
"type": "number",
|
|
483
|
+
"nullable": false
|
|
484
|
+
},
|
|
485
|
+
"required": true
|
|
486
|
+
}
|
|
487
|
+
],
|
|
488
|
+
"requestBody": {
|
|
489
|
+
"description": "Content to write",
|
|
490
|
+
"content": {
|
|
491
|
+
"application/json": {
|
|
492
|
+
"schema": {
|
|
493
|
+
"$ref": "#/components/schemas/ISaleComment.IStore"
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
"required": true
|
|
498
|
+
},
|
|
499
|
+
"responses": {
|
|
500
|
+
"201": {
|
|
501
|
+
"description": "Newly archived comment",
|
|
502
|
+
"content": {
|
|
503
|
+
"application/json": {
|
|
504
|
+
"schema": {
|
|
505
|
+
"$ref": "#/components/schemas/ISaleComment"
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
"400": {
|
|
511
|
+
"description": "bad request error when type of the input data is not valid"
|
|
512
|
+
},
|
|
513
|
+
"401": {
|
|
514
|
+
"description": "unauthorized error when you've not logged in yet"
|
|
515
|
+
},
|
|
516
|
+
"403": {
|
|
517
|
+
"description": "forbidden error when you're a seller and the sale is not yours"
|
|
518
|
+
},
|
|
519
|
+
"404": {
|
|
520
|
+
"description": "not found error when unable to find the matched record"
|
|
521
|
+
}
|
|
522
|
+
},
|
|
523
|
+
"description": "Store a new comment."
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
},
|
|
527
|
+
"components": {
|
|
528
|
+
"schemas": {
|
|
529
|
+
"ISaleComment": {
|
|
530
|
+
"type": "object",
|
|
531
|
+
"properties": {
|
|
532
|
+
"id": {
|
|
533
|
+
"description": "Primary Key.",
|
|
534
|
+
"type": "number",
|
|
535
|
+
"nullable": false
|
|
536
|
+
},
|
|
537
|
+
"writer_type": {
|
|
538
|
+
"description": "Type of the writer.",
|
|
539
|
+
"type": "string",
|
|
540
|
+
"nullable": false
|
|
541
|
+
},
|
|
542
|
+
"writer_name": {
|
|
543
|
+
"description": "Name of the writer.",
|
|
544
|
+
"type": "string",
|
|
545
|
+
"nullable": false
|
|
546
|
+
},
|
|
547
|
+
"contents": {
|
|
548
|
+
"description": "Contents of the comments.\n\nWhen the comment writer tries to modify content, it would not modify the comment\ncontent but would be accumulated. Therefore, all of the people can read how\nthe content has been changed.",
|
|
549
|
+
"type": "array",
|
|
550
|
+
"items": {
|
|
551
|
+
"$ref": "#/components/schemas/ISaleComment.IContent"
|
|
552
|
+
},
|
|
553
|
+
"nullable": false
|
|
554
|
+
},
|
|
555
|
+
"created_at": {
|
|
556
|
+
"description": "Creation time.",
|
|
557
|
+
"type": "string",
|
|
558
|
+
"nullable": false
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
"nullable": false,
|
|
562
|
+
"required": [
|
|
563
|
+
"id",
|
|
564
|
+
"writer_type",
|
|
565
|
+
"writer_name",
|
|
566
|
+
"contents",
|
|
567
|
+
"created_at"
|
|
568
|
+
],
|
|
569
|
+
"description": "Comment wrote on an article."
|
|
570
|
+
},
|
|
571
|
+
"ISaleComment.IContent": {
|
|
572
|
+
"type": "object",
|
|
573
|
+
"properties": {
|
|
574
|
+
"created_at": {
|
|
575
|
+
"description": "Creation time.",
|
|
576
|
+
"type": "string",
|
|
577
|
+
"nullable": false
|
|
578
|
+
},
|
|
579
|
+
"body": {
|
|
580
|
+
"description": "Body of the content.",
|
|
581
|
+
"type": "string",
|
|
582
|
+
"nullable": false
|
|
583
|
+
}
|
|
584
|
+
},
|
|
585
|
+
"nullable": false,
|
|
586
|
+
"required": [
|
|
587
|
+
"created_at",
|
|
588
|
+
"body"
|
|
589
|
+
],
|
|
590
|
+
"description": "Content info."
|
|
591
|
+
},
|
|
592
|
+
"ISaleComment.IStore": {
|
|
593
|
+
"type": "object",
|
|
594
|
+
"properties": {
|
|
595
|
+
"body": {
|
|
596
|
+
"description": "Body of the content.",
|
|
597
|
+
"type": "string",
|
|
598
|
+
"nullable": false
|
|
599
|
+
}
|
|
600
|
+
},
|
|
601
|
+
"nullable": false,
|
|
602
|
+
"required": [
|
|
603
|
+
"body"
|
|
604
|
+
],
|
|
605
|
+
"description": "Store info."
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
```
|
|
611
|
+
|
|
612
|
+
|
|
351
613
|
|
|
352
614
|
|
|
353
615
|
|
|
@@ -357,7 +619,7 @@ https://github.com/samchon/backend
|
|
|
357
619
|
|
|
358
620
|
I support template backend project using this **Nestia*** library, [backend](https://github.com/samchon/backend).
|
|
359
621
|
|
|
360
|
-
|
|
622
|
+
Reading the README content of the [backend](https://github.com/samchon/backend) template repository, you can find lots of example backend projects who've been generated from the [backend](https://github.com/samchon/backend). Furthermore, those example projects guide how to generate SDK library from the **Nestia** and how to distribute the SDK library thorugh the NPM module.
|
|
361
623
|
|
|
362
624
|
Therefore, if you're planning to compose your own backend project using this **Nestia**, I recommend you to create the repository and learn from the [backend](https://github.com/samchon/backend) template project.
|
|
363
625
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ControllerAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,yBAAiB,kBAAkB,CACnC;IACI,SAAgB,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,CAc7G;
|
|
1
|
+
{"version":3,"file":"ControllerAnalyzer.d.ts","sourceRoot":"","sources":["../../src/analyses/ControllerAnalyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAM9C,yBAAiB,kBAAkB,CACnC;IACI,SAAgB,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,GAAG,MAAM,EAAE,CAc7G;CA2IJ"}
|
|
@@ -134,7 +134,9 @@ var ControllerAnalyzer;
|
|
|
134
134
|
// EXPLORE CHILDREN TYPES
|
|
135
135
|
var parameters = func.parameters.map(function (param) { return _Analyze_parameter(checker, genericDict, importDict, controller, func.name, param, declaration.parameters[param.index]); });
|
|
136
136
|
var output = ImportAnalyzer_1.ImportAnalyzer.analyze(checker, genericDict, importDict, checker.getReturnTypeOfSignature(signature));
|
|
137
|
-
var imports = importDict
|
|
137
|
+
var imports = importDict
|
|
138
|
+
.toJSON()
|
|
139
|
+
.map(function (pair) { return [pair.first, pair.second.toJSON()]; });
|
|
138
140
|
// CONFIGURE PATH
|
|
139
141
|
var path = _Normalize_path(path_1.default.join(controller.path, func.path)
|
|
140
142
|
.split("\\")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommentFactory.d.ts","sourceRoot":"","sources":["../../src/factories/CommentFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,yBAAiB,cAAc,CAC/B;IACI,SAAgB,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,EAAE,GAAG,MAAM,CAMjE;CACJ"}
|