nestia 4.0.4 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -122
- package/bin/NestiaSetupWizard.js +2 -1
- package/bin/NestiaSetupWizard.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,13 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
Nestia is a set of helper libraries for NestJS, supporting below features:
|
|
7
7
|
|
|
8
|
-
- [`@nestia/core`](#nestiacore): **15,000x times faster** validation
|
|
9
|
-
- [`@nestia/sdk`](#nestiasdk): evolved **SDK** and **Swagger**
|
|
8
|
+
- [`@nestia/core`](#nestiacore): **15,000x times faster** validation decorators
|
|
9
|
+
- [`@nestia/sdk`](#nestiasdk): evolved **SDK** and **Swagger** generators
|
|
10
|
+
- SDK (Software Development Kit)
|
|
11
|
+
- interaction library for client developers
|
|
12
|
+
- almost same with [tRPC](https://github.com/trpc/trpc)
|
|
10
13
|
- `nestia`: just CLI (command line interface) tool
|
|
11
14
|
|
|
12
|
-
%20Core(TM)%20i5-1135G7%20%40%202.40GHz#is)
|
|
15
|
+

|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -55,7 +56,7 @@ npx ts-node -C ttypescript src/index.ts
|
|
|
55
56
|
```
|
|
56
57
|
|
|
57
58
|
### Manual Setup
|
|
58
|
-
If you want to install and configure `nestia` manually, read [Guide Documents
|
|
59
|
+
If you want to install and configure `nestia` manually, read [Guide Documents -> Setup](https://github.com/samchon/nestia/wiki/Setup).
|
|
59
60
|
|
|
60
61
|
|
|
61
62
|
|
|
@@ -97,65 +98,20 @@ export class BbsArticlesController {
|
|
|
97
98
|
}
|
|
98
99
|
```
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
`TypedBody()` is a decorator function of `application/json` typed request body.
|
|
102
|
-
|
|
103
|
-
Also, it supports super-fast validation pipe, which is maximum **15,000x times faster** then `nest.Body()` function using `class-validator`.
|
|
104
|
-
|
|
105
|
-
### TypedRoute
|
|
106
|
-
`TypedRoute` is a set of decorator functions for `application/json` typed response body.
|
|
107
|
-
|
|
108
|
-
Also, it supports safe and fast JSON stringify function pipe, which is maximum 10x times faster than native `JSON.stringify()` function. Furthermore, it is **type safe** through validation.
|
|
101
|
+
If you want to know more about this core library, visit [Guide Documents](https://github.com/samchon/nestia/wiki).
|
|
109
102
|
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
export interface IBbsArticle {
|
|
123
|
-
/**
|
|
124
|
-
* @format uuid
|
|
125
|
-
*/
|
|
126
|
-
id: string;
|
|
127
|
-
|
|
128
|
-
writer: IBbsArticle.IWriter;
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* @minItems 1
|
|
132
|
-
*/
|
|
133
|
-
contents: IBbsArticle.IContent[];
|
|
134
|
-
}
|
|
135
|
-
export namespace IBbsArticle {
|
|
136
|
-
export interface IWriter {
|
|
137
|
-
/**
|
|
138
|
-
* @minLength 3
|
|
139
|
-
*/
|
|
140
|
-
name: string;
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* @format email
|
|
144
|
-
*/
|
|
145
|
-
email: string;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @pattern ^0[0-9]{7,16}
|
|
149
|
-
*/
|
|
150
|
-
mobile: string;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* @minimum 18
|
|
154
|
-
*/
|
|
155
|
-
age: number;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
```
|
|
103
|
+
- Decorators
|
|
104
|
+
- [TypedRoute](https://github.com/samchon/nestia/wiki/Core-Library#typedroute)
|
|
105
|
+
- [TypedBody](https://github.com/samchon/nestia/wiki/Core-Library#typedbody)
|
|
106
|
+
- [TypedQuery](https://github.com/samchon/nestia/wiki/Core-Library#typedquery)
|
|
107
|
+
- [TypedParam](https://github.com/samchon/nestia/wiki/Core-Library#typedparam)
|
|
108
|
+
- Enhancements
|
|
109
|
+
- [Comment Tags](https://github.com/samchon/nestia/wiki/Core-Library#comment-tags)
|
|
110
|
+
- [Configuration](https://github.com/samchon/nestia/wiki/Core-Library#configuration)
|
|
111
|
+
- Advanced Usage
|
|
112
|
+
- [DynamicModule](https://github.com/samchon/nestia/wiki/Core-Library#dynamicmodule)
|
|
113
|
+
- [Encryption](https://github.com/samchon/nestia/wiki/Core-Library#encryption)
|
|
114
|
+
- [Inheritance](https://github.com/samchon/nestia/wiki/Core-Library#inheritance)
|
|
159
115
|
|
|
160
116
|
|
|
161
117
|
|
|
@@ -168,7 +124,7 @@ Automatic *SDK* and *Swagger* generator for [@nestia/core](#nestiacore).
|
|
|
168
124
|
|
|
169
125
|
With [@nestia/core](#nestiacore), you can boost up validation speed maximum **15,000x times faster**. However, as `@nestjs/swagger` does not support [@nestia/core](#nestiacore), you can't generate swagger documents from `@nestjs/swagger` more.
|
|
170
126
|
|
|
171
|
-
Instead, I provide you `@nestia/sdk` module, which can generate not only swagger documents, but also SDK (Software Development Kit) library.
|
|
127
|
+
Instead, I provide you `@nestia/sdk` module, which can generate not only swagger documents, but also SDK (Software Development Kit) library. The SDK library can be utilized by client developers and it is almost same with `tRPC`.
|
|
172
128
|
|
|
173
129
|
### Usage
|
|
174
130
|
```bash
|
|
@@ -180,71 +136,31 @@ npx nestia <sdk|swagger> <source_directories_or_patterns> \
|
|
|
180
136
|
# EXAMPLES
|
|
181
137
|
npx nestia sdk "src/**/*.controller.ts" --out "src/api"
|
|
182
138
|
npx nestia swagger "src/controllers" --out "dist/swagger.json"
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
You can generate sdk or swagger documents by above commands.
|
|
186
|
-
|
|
187
|
-
If you've configured `nestia.config.ts` file, you can omit all options like below. About the `nestia.config.ts` file, read [Guide Documents - Configuration](https://github.com/samchon/nestia/wiki/Configuration)
|
|
188
139
|
|
|
189
|
-
|
|
140
|
+
# ONLY WHEN "nestia.config.ts" FILE EXISTS
|
|
190
141
|
npx nestia sdk
|
|
191
142
|
npx nestia swagger
|
|
192
143
|
```
|
|
193
144
|
|
|
194
|
-
|
|
195
|
-
When you generate SDK library through `npx nestia sdk` command, `@nestia/sdk` will generate below code, by analyzing your backend source code in the compilation level.
|
|
196
|
-
|
|
197
|
-
```typescript
|
|
198
|
-
import { Fetcher, IConnection } from "@nestia/fetcher";
|
|
199
|
-
import { IBbsArticle } from "../../../structures/IBbsArticle";
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Store a new content.
|
|
203
|
-
*
|
|
204
|
-
* @param input Content to store
|
|
205
|
-
* @returns Newly archived article
|
|
206
|
-
*/
|
|
207
|
-
export function store(
|
|
208
|
-
connection: api.IConnection,
|
|
209
|
-
input: IBbsArticle.IStore
|
|
210
|
-
): Promise<IBbsArticle> {
|
|
211
|
-
return Fetcher.fetch(
|
|
212
|
-
connection,
|
|
213
|
-
store.ENCRYPTED,
|
|
214
|
-
store.METHOD,
|
|
215
|
-
store.path(),
|
|
216
|
-
input
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
export namespace store {
|
|
220
|
-
export const METHOD = "POST" as const;
|
|
221
|
-
export function path(): string {
|
|
222
|
-
return "/bbs/articles";
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
```
|
|
145
|
+
You can generate sdk or swagger documents by above commands.
|
|
226
146
|
|
|
227
|
-
|
|
147
|
+
If you want to know more, visit [Guide Documents](https://github.com/samchon/nestia/wiki).
|
|
228
148
|
|
|
229
|
-
|
|
149
|
+
- Generators
|
|
150
|
+
- [Swagger Documents](https://github.com/samchon/nestia/wiki/SDK-Generator#swagger-documents)
|
|
151
|
+
- [SDK Library](https://github.com/samchon/nestia/wiki/SDK-Generator#sdk-library)
|
|
152
|
+
- Advanced Usage
|
|
153
|
+
- [Comment Tags](https://github.com/samchon/nestia/wiki/SDK-Generator#comment-tags)
|
|
154
|
+
- [Configuration](https://github.com/samchon/nestia/wiki/SDK-Generator#configuration)
|
|
230
155
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
import typia from "typia";
|
|
156
|
+
### Demonstration
|
|
157
|
+
Here is example projects building Swagger Documents and SDK Library with `npx nestia swagger` and `npx nestia sdk` comands. `@nestia/sdk` generates those documents and libraries by analyzing your NestJS backend server code in the compilation level.
|
|
234
158
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
title: "some title",
|
|
241
|
-
content: "some content",
|
|
242
|
-
}
|
|
243
|
-
);
|
|
244
|
-
typia.assert(article);
|
|
245
|
-
console.log(article);
|
|
246
|
-
}
|
|
247
|
-
```
|
|
159
|
+
Project | Controller | SDK | Swagger
|
|
160
|
+
--------|------------|-----|---------
|
|
161
|
+
`npx nestia start` | [`BbsArticlesController`](https://github.com/samchon/nestia-template/blob/master/src/controllers/BbsArticlesController.ts) | [Functions](https://github.com/samchon/nestia-template/blob/master/src/api/functional/bbs/articles/index.ts) | [Editor](https://editor.swagger.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsamchon%2Fnestia-template%2Fmaster%2Fdist%2Fswagger.json)
|
|
162
|
+
[fake-iamport](https://github.com/samchon/fake-iamport-server) | [`IamportCertificationsController`](https://github.com/samchon/fake-iamport-server/blob/master/src/controllers/FakeIamportCertificationsController.ts) | [Functions](https://github.com/samchon/fake-iamport-server/blob/master/src/api/functional/certifications/index.ts) | [Editor](https://editor.swagger.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsamchon%2Ffake-iamport-server%2Fmaster%2Fdist%2Fswagger.json)
|
|
163
|
+
[fake-toss-payments](https://github.com/samchon/fake-toss-payments-server) | [`TossPaymentsController`](https://github.com/samchon/fake-toss-payments-server/blob/master/src/controllers/FakeTossPaymentsController.ts) | [Functions](https://github.com/samchon/fake-toss-payments-server/blob/master/src/api/functional/v1/payments/index.ts) | [Editor](https://editor.swagger.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsamchon%2Ffake-toss-payments-server%2Fmaster%2Fdist%2Fswagger.json)
|
|
248
164
|
|
|
249
165
|
|
|
250
166
|
|
|
@@ -288,4 +204,59 @@ export function assertStringify<T>(input: T): string; // safe and faster
|
|
|
288
204
|
|
|
289
205
|
All functions in `typia` require **only one line**. You don't need any extra dedication like JSON schema definitions or decorator function calls. Just call `typia` function with only one line like `typia.assert<T>(input)`.
|
|
290
206
|
|
|
291
|
-
Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance is much faster than other competitive libaries. For an example, when comparing validate function `is()` with other competitive libraries, `typia` is maximum **15,000x times faster** than `class-validator`.
|
|
207
|
+
Also, as `typia` performs AOT (Ahead of Time) compilation skill, its performance is much faster than other competitive libaries. For an example, when comparing validate function `is()` with other competitive libraries, `typia` is maximum **15,000x times faster** than `class-validator`.
|
|
208
|
+
|
|
209
|
+
### Reactia
|
|
210
|
+
> https://github.com/samchon/reactia
|
|
211
|
+
>
|
|
212
|
+
> Not published yet, but soon
|
|
213
|
+
|
|
214
|
+
[](https://github.com/samchon/reactia/blob/master/LICENSE)
|
|
215
|
+
[](https://github.com/samchon/reactia/actions?query=workflow%3Abuild)
|
|
216
|
+
[](https://github.com/samchon/reactia/wiki)
|
|
217
|
+
|
|
218
|
+
Reactia is an automatic React components generator, just by analyzing TypeScript type.
|
|
219
|
+
|
|
220
|
+
- `@reactia/core`: Core Library analyzing TypeScript type
|
|
221
|
+
- `@reactia/mui`: Material UI Theme for `core` and `nest`
|
|
222
|
+
- `@reactia/nest`: Automatic Frontend Application Builder for `NestJS`
|
|
223
|
+
<!-- - `reactia`: Just CLI tool -->
|
|
224
|
+
|
|
225
|
+

|
|
226
|
+
|
|
227
|
+
When you want to automate an individual component, just use `@reactia/core`.
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import ReactDOM from "react-dom";
|
|
231
|
+
|
|
232
|
+
import typia from "typia";
|
|
233
|
+
import { ReactiaComponent } from "@reactia/core";
|
|
234
|
+
import { MuiInputTheme } from "@reactia/mui";
|
|
235
|
+
|
|
236
|
+
const RequestInput = ReactiaComponent<IRequestDto>(MuiInputTheme());
|
|
237
|
+
const input: IRequestDto = { ... };
|
|
238
|
+
|
|
239
|
+
ReactDOM.render(
|
|
240
|
+
<RequestInput input={input} />,
|
|
241
|
+
document.body
|
|
242
|
+
);
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Otherwise, you can fully automate frontend application development through `@reactia/nest`.
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
import React from "react";
|
|
249
|
+
import ReactDOM from "react-dom";
|
|
250
|
+
|
|
251
|
+
import { ISwagger } "@nestia/swagger";
|
|
252
|
+
import { MuiApplicationTheme } from "@reactia/mui";
|
|
253
|
+
import { ReactiaApplication } from "@reactia/nest";
|
|
254
|
+
|
|
255
|
+
const swagger: ISwagger = await import("./swagger.json");
|
|
256
|
+
const App: React.FC = ReactiaApplication(MuiApplicationTheme())(swagger);
|
|
257
|
+
|
|
258
|
+
ReactDOM.render(
|
|
259
|
+
<App />,
|
|
260
|
+
document.body
|
|
261
|
+
);
|
|
262
|
+
```
|
package/bin/NestiaSetupWizard.js
CHANGED
|
@@ -61,7 +61,8 @@ var NestiaSetupWizard;
|
|
|
61
61
|
halt(() => { })("make package.json file or move to it.");
|
|
62
62
|
const pack = JSON.parse(yield fs_1.default.promises.readFile("package.json", "utf8"));
|
|
63
63
|
add(args.manager)(pack)("@nestia/core", false);
|
|
64
|
-
add(args.manager)(pack)("@nestia/sdk",
|
|
64
|
+
add(args.manager)(pack)("@nestia/sdk", true);
|
|
65
|
+
add(args.manager)(pack)("nestia", true);
|
|
65
66
|
const modulo = yield (_a = process.cwd() +
|
|
66
67
|
"/node_modules/@nestia/core/lib/executable/internal/CoreSetupWizard", Promise.resolve().then(() => __importStar(require(_a))));
|
|
67
68
|
return modulo.CoreSetupWizard;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NestiaSetupWizard.js","sourceRoot":"","sources":["../src/NestiaSetupWizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA+B;AAC/B,4CAAoB;AAEpB,IAAiB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"NestiaSetupWizard.js","sourceRoot":"","sources":["../src/NestiaSetupWizard.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA+B;AAC/B,4CAAoB;AAEpB,IAAiB,iBAAiB,CAkCjC;AAlCD,WAAiB,iBAAiB;IAM9B,SAAsB,WAAW,CAAC,IAAgB;;YAC9C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;KAAA;IAHqB,6BAAW,cAGhC,CAAA;IAED,SAAsB,OAAO,CAAC,IAAgB;;YAC1C,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;YACnC,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,CAAC;KAAA;IAHqB,yBAAO,UAG5B,CAAA;IAED,SAAe,OAAO,CAAC,IAAgB;;;YACnC,IAAI,YAAE,CAAC,UAAU,CAAC,cAAc,CAAC,KAAK,KAAK;gBACvC,IAAI,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC,uCAAuC,CAAC,CAAC;YAE5D,MAAM,IAAI,GAAQ,IAAI,CAAC,KAAK,CACxB,MAAM,YAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,CACrD,CAAC;YACF,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;Y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