@samchon/bbs-api
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

SDK for Client Developers

Outline

@samchon/bbs-backend provides SDK (Software Development Kit) for convenience.

For the client developers who are connecting to this backend server, @samchon/bbs-backend provides not API documents like the Swagger, but provides the API interaction library, one of the typical SDK (Software Development Kit) for the convenience.

With the SDK, client developers never need to re-define the duplicated API interfaces. Just utilize the provided interfaces and asynchronous functions defined in the SDK. It would be much convenient than any other Rest API solutions.

npm install --save @samchon/bbs-api

Usage

Import the @samchon/bbs-api and enjoy the auto-completion.

import { ArrayUtil, RandomGenerator, TestValidator } from "@nestia/e2e";
import { randint } from "tstl";
import typia from "typia";

import api from "@samchon/bbs-api/lib/index";
import { IBbsArticle } from "@samchon/bbs-api/lib/structures/bbs/IBbsArticle";

import { prepare_random_file } from "./internal/prepare_random_file";

export const test_api_bbs_article_create = async (
  connection: api.IConnection,
): Promise<void> => {
  // PREPARE INPUT DATA
  const input: IBbsArticle.ICreate = {
    writer: RandomGenerator.name(),
    password: RandomGenerator.alphaNumeric(8),
    title: RandomGenerator.paragraph()(),
    body: RandomGenerator.content()()(),
    format: "md",
    files: ArrayUtil.repeat(randint(0, 3))(() => prepare_random_file()),
  };

  // DO CREATE
  const article: IBbsArticle = await api.functional.bbs.articles.create(
    connection,
    input,
  );
  typia.assertEquals(article);

  // VALIDATE WHETHER EXACT DATA IS INSERTED
  TestValidator.equals("create")({
    snapshots: [
      {
        format: input.format,
        title: input.title,
        body: input.body,
        files: input.files,
      },
    ],
    writer: input.writer,
  })(article);

  // COMPARE WITH READ DATA
  const read: IBbsArticle = await api.functional.bbs.articles.at(
    connection,
    article.id,
  );
  typia.assertEquals(read);
  TestValidator.equals("read")(read)(article);
};

Readme

Keywords

none

Package Sidebar

Install

npm i @samchon/bbs-api

Weekly Downloads

1

Version

3.0.0

License

MIT

Unpacked Size

329 kB

Total Files

86

Last publish

Collaborators

  • samchon