@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
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);
};