Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestia/sdk

Package Overview
Dependencies
Maintainers
1
Versions
480
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestia/sdk

Nestia SDK and Swagger generator

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.6K
decreased by-23.35%
Maintainers
1
Weekly downloads
 
Created
Source

Nestia SDK

GitHub license npm version Downloads Build Status Guide Documents

Automatic SDK and Swagger generator for @nestia/core.

With @nestia/core, you can boost up validation speed maximum 15,000x times faster. However, as @nestjs/swagger does not support @nestia/core, you can't generate swagger documents from @nestjs/swagger more.

Instead, I provide you @nestia/sdk module, which can generate not only swagger documents, but also SDK (Software Development Kit) library.

Setup

Boilerplate Project

npx nestia start <directory>

Just run above command, then boilerplate project would be constructed.

Setup Wizard

npx nestia setup

When you want to use nestia in orindary project, just type above command.

All installation and configuration processes would be automatically done.

Also, you can specify package manager by --manage argument like below:

npx nestia setup --manager npm
npx nestia setup --manager pnpm
npx nestia setup --manager yarn

Sole Setup

If you want to install and setup @nestia/sdk only, just do it.

npm install --save-dev @nestia/sdk

Usage

# BASIC COMMAND
npx nestia <sdk|swagger> <source_directories_or_patterns> \
    --exclude <exclude_directory_or_pattern> \
    --out <output_directory_or_file>

# EXAMPLES
npx nestia sdk "src/**/*.controller.ts" --out "src/api"
npx nestia swagger "src/controllers" --out "dist/swagger.json"

You can generate sdk or swagger documents by above commands.

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

npx nestia sdk
npx nestia swagger

Demonstration

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.

import { Fetcher, IConnection } from "@nestia/fetcher";
import { IBbsArticle } from "../../../structures/IBbsArticle";

/**
 * Store a new content.
 * 
 * @param input Content to store
 * @returns Newly archived article
 */
export function store(
    connection: api.IConnection, 
    input: IBbsArticle.IStore
): Promise<IBbsArticle> {
    return Fetcher.fetch(
        connection,
        store.ENCRYPTED,
        store.METHOD,
        store.path(),
        input
    );
}
export namespace store {
    export const METHOD = "POST" as const;
    export function path(): string {
        return "/bbs/articles";
    }
}

With SDK library, client developers would get take advantages of TypeScript like below.

If you want to learn how to distribute SDK library, visit and read Guide Documents - Distribution.

import api from "@bbs-api";
import typia from "typia";

export async function test_bbs_article_store(connection: api.IConnection) {
    const article: IBbsArticle = await api.functional.bbs.articles.store(
        connection,
        {
            name: "John Doe",
            title: "some title",
            content: "some content",
        }
    );
    typia.assert(article);
    console.log(article);
}

Keywords

FAQs

Package last updated on 17 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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