Socket
Socket
Sign inDemoInstall

nestia

Package Overview
Dependencies
Maintainers
1
Versions
222
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nestia - npm Package Compare versions

Comparing version 0.3.0-dev.20210923 to 0.3.0

2

package.json
{
"name": "nestia",
"version": "0.3.0-dev.20210923",
"version": "0.3.0",
"description": "Automatic SDK and Document generator for the NestJS",

@@ -5,0 +5,0 @@ "main": "src/index.ts",

@@ -64,3 +64,3 @@ # Nestia

npx nestia sdk "src/controllers" --out "src/api"
npx nestia sdk "src/consumers/controllers" "src/sellers/controllers" --out "src/api
npx nestia sdk "src/controllers/consumers" "src/controllers/sellers" --out "src/api
```

@@ -72,3 +72,3 @@

Also, when generating a SDK using the cli options, `compilerOptions` would follow the `tsconfig.json`. If no `tsconfig.json` file exists in your project, the configuration would be the `ES5` with `strict` mode. If you want to use different `compilerOptions` with the `tsconfig.json`, you should configure the [nestia.config.ts](#nestiaconfigts).
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).

@@ -80,4 +80,6 @@ ```bash

### Dependencies
SDK library generated by the **Nestia** has some dependencies like below. When you type the `nestia install` command in the console, those dependencies would be automatically installed and enrolled to the `dependencies` field in the `package.json`
SDK library generated by the **Nestia** has some dependencies like below.
When you type the `nestia install` command in the console, those dependencies would be automatically installed and enrolled to the `dependencies` and `devDependencies` fields in the `package.json`
- [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node)

@@ -90,13 +92,4 @@ - [node-fetch](https://github.com/node-fetch/node-fetch)

## Advanced
### `NestiaApplication`
### `nestia.config.ts`
```typescript
import tsc from "typescript";
export class NestiaApplication
{
public constructor(config: NestiaApplication.IConfiguration);
public generate(): Promise<void>;
public simulate(): Promise<void>;
}
export namespace NestiaApplication

@@ -109,3 +102,3 @@ {

*/
input: string[];
input: string | string[];

@@ -127,13 +120,46 @@ /**

### `nestia.config.ts`
Instead of specifying `input` and `output` directories using the cli options, you can specify those directories as an independent configuration file. It's the `nestia.config.ts` and with the `nestia.config.ts` file, you also configure independent TypeScript compiler option from the `tsconfig.json`.
Write below content as the `nestia.config.ts` file and place it onto the root directory of your backend project. After the configuration, you can generate the SDK only with the `npx nestia sdk` command, without any directory specification.
```typescript
export = {
input: "src/controllers`",
output: "src/api"
};
```
### Recommended Structures
When developing a NestJS backend server with this **Nestia**, I recommend you to follow below directory structure. The key princinple of below structure is to gathering all of the DTO interface structures into the `src/api/structures` directory and gather all of the controller classes into the `src/controllers` directory.
If you place the SDK onto the `src/api` directory and gather all of the DTO interface structures into the `src/api/structures` directory, you can publish the SDK library very easily without any special configuration. Also when you're develop the test automation program, you can implement the API testing features very convenienty through the automatically generated SDK through this **Nestia**.
- src
- api
- **functional**: automatically generated SDK functions
- **structures**: DTO structures
- controllers
- providers
- models
- **test**: Test automation program using SDK functions
- package.json
- tsconfig.json
- nestia.config.ts
For your deep understanding about this directory structure with this **Nestia**, I've prepared an example backend project. Looking around the example repository and reading the [README.md](https://github.com/samchon/backend#13-directories) of it, you can feel that such directory structure is how convenient for SDK publishing and test automation program implementation.
- https://github.com/samchon/backend
## Demonstration
- [Controllers of the NestJS](https://github.surf/samchon/nestia/blob/HEAD/src/test/controllers/base/SaleCommentsController.ts)
- [Structures used in the RestAPI](https://github.surf/samchon/nestia/blob/HEAD/api/structures/sales/articles/ISaleArticle.ts)
- [SDK generated by this **Nestia**](https://github.surf/samchon/nestia/blob/HEAD/api/functional/consumers/sales/reviews/index.ts)
To demonstrate which SDK codes would be generated by this **Nestia**:
- [Controllers of the NestJS](https://github.surf/samchon/nestia/blob/HEAD/test/default/src/controllers/base/SaleCommentsController.ts)
- [Structures used in the RestAPI](https://github.surf/samchon/nestia/blob/HEAD/test/default/src/api/structures/sales/articles/ISaleArticle.ts)
- [SDK generated by this **Nestia**](https://github.surf/samchon/nestia/blob/HEAD/test/default/src/api/functional/consumers/sales/reviews/index.ts)
### Controller

@@ -216,2 +242,30 @@ 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.

}
```
```
## Appendix
### Safe-TypeORM
https://github.com/samchon/safe-typeorm
[safe-typeorm](https://github.com/samchon/safe-typeorm) is another library that what I've developed, helping typeorm in the compilation level and optimizes DB performance automatically without any extra dedication.
Therefore, this **Nestia** makes you to be much convenient in the API interaction level and safe-typeorm helps you to be much convenient in the DB interaction level. With those **Nestia** and [safe-typeorm](https://github.com/samchon/safe-typeorm), let's implement the backend server much easily and conveniently.
### Technial Support
samchon.github@gmail.com
I get technical support about this **Nestia** and [safe-typeorm](https://github.com/samchon/safe-typeorm).
Therefore, if you have any question or need help, feel free to contact me. If you want to adapt this **Nestia** and [safe-typeorm](https://github.com/samchon/safe-typeorm) in your commercial project, I can provide you the best guidance.
I also can help your backend project in the entire development level. If you're suffering by DB architecture design or API structure design, just contact me and get help. I'll help you with my best effort.
### Archidraw
https://www.archisketch.com/
I have special thanks to the Archidraw, where I'm working for.
The Archidraw is a great IT company developing 3D interior editor and lots of solutions based on the 3D assets. Also, the Archidraw is the first company who had adopted this **Nestia** on their commercial backend project, even this **Nestia** was in the alpha level.

@@ -29,3 +29,3 @@ #!/usr/bin/env ts-node-script

compilerOptions = config.compilerOptions;
input = config.input;
input = config.input instanceof Array ? config.input : [config.input];
command.out = config.output;

@@ -32,0 +32,0 @@ }

@@ -29,3 +29,3 @@ import * as fs from "fs";

{
const relative: string = `${config.output}${path.sep}${file}`;
const relative: string = `${this.config_.output}${path.sep}${file}`;
const stats: fs.Stats = await fs.promises.stat(`${__dirname}${path.sep}bundle${path.sep}${file}`);

@@ -52,3 +52,7 @@

const fileList: string[] = [];
for (const file of this.config_.input.map(str => path.resolve(str)))
const inputList: string[] = this.config_.input instanceof Array
? this.config_.input
: [this.config_.input];
for (const file of inputList.map(str => path.resolve(str)))
{

@@ -101,3 +105,3 @@ const found: string[] = await SourceFinder.find(file);

{
input: string[];
input: string | string[];
output: string;

@@ -104,0 +108,0 @@ compilerOptions?: tsc.CompilerOptions;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc