https://github.com/samchon/nestjs-study-router-module
To support RouterModule in Nestia
https://github.com/samchon/nestjs-study-router-module
Last synced: 5 months ago
JSON representation
To support RouterModule in Nestia
- Host: GitHub
- URL: https://github.com/samchon/nestjs-study-router-module
- Owner: samchon
- License: mit
- Created: 2023-10-17T18:06:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-10-18T12:25:28.000Z (over 2 years ago)
- Last Synced: 2026-01-19T10:53:43.448Z (5 months ago)
- Language: TypeScript
- Size: 31.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Nestia Template
## Outline
[](https://github.com/samchon/nestia-template/actions?query=workflow%3Abuild)
A template repository for backend projects using [nestia](https://github.com/samchon/nestia).
You can create a new project from this boilerplate by running below command:
```bash
npx nestia start
```
For reference, this is a minimal boilerplate project concentrating only on [nestia](https://github.com/samchon/nestia) SDK generation. If you wanna much detailed boilerplate project even configured DB and Non-distruptive update system, visit [samchon/backend](https://github.com/samchon/backend) and create a new repository from that.
## Directories and Files
This template project has categorized directories like below.
As you can see from the below, all of the Backend source files are placed into the [src](src/) directory. When you build the TypeScript source files, compiled files would be placed into the `lib` directory following the [tsconfig.json](tsconfig.json) configuration. Otherwise you build client [SDK](#32-sdk) library for npm publishing and their compiled files would be placed into the [packages](packages) directory.
- [packages/api/](packages/api): SDK module built by `npm run build:api`
- [src/](src): Backend source directory
- [src/api/](src/api/): Client SDK that would be published to the `@ORGANIZATION/PROJECT-api`
- [**src/api/functional/**](src/api/functional/): API functions generated by the [`nestia`](https://github.com/samchon/nestia)
- [**src/api/structures/**](src/api/structures/): DTO structures
- [src/controllers/](src/controllers/): Controller classes of the Main Program
- [**test/**](test): Test Automation Program
- [nestia.config.ts](nestia.config.ts): Configuration file of [`nestia`](https://github.com/samchon/nestia)
- [package.json](package.json): NPM configuration
- [tsconfig.json](tsconfig.json): TypeScript configuration for the main program
- [tsconfig.api.json](tsconfig.api.json): TypeScript configuration for the SDK generation
## NPM Run Commands
List of the run commands defined in the [package.json](package.json) are like below:
- `build`: Build everything
- `build:api`: Build client SDK libray for the client developers
- `build:main`: Build main program (`src` directory)
- `build:sdk`: Build SDK into main program only
- `build:swagger`: Build Swagger Documents
- `build:test` Build test automation program (`test` directory)
- `dev`: Incremental build for development (test program)
- `eslint` & `eslint:fix` & `prettier`: Prettier and ESLint execution
- `start`: Start local NestJS server
- `test`: Run test automation program
## Specialization
Transform this template project to be yours.
When you've created a new backend project through this template project, you can specialize it to be suitable for you by changing some words. Replace below words through IDE specific function like `Edit > Replace in Files` (*Ctrl + Shift + H*), who've been supported by the VSCode.
| Before | After
|-----------------|----------------------------------------
| ORGANIZATION | Your account or corporation name
| PROJECT | Your own project name
| AUTHOR | Author name
| https://github.com/samchon/nestia-template | Your repository URL
## Test Driven Development
With [nestia](https://github.com/samchon/nestia) helps to accomplish TDD (Test Driven Development).
Just define DTOs and API controllers' methods (only declarations) first. After the definitions, and build SDK (Software Development Kit) through [nestia](https://github.com/samchon/nestia) (`npm run build:sdk`). After buildling those SDK, develop test automation program using the SDK, following use-case scenarios in the framework of client side.
During the test automation program development, you can find that which API is mis-designed or which requirement analysis is not exact. Development of the main program must be the last step after such validation process during TDD.
> Visit the [samchon/backend](https://github.com/samchon/backend), then you may find much detailed story about this TDD.
>
> 1. Definitions
> 2. SDK
> 3. Test Automation Program
> 4. Main Program
```typescript
import typia from "typia";
import api from "@ORGANIZATION/PROJECT-api/lib/index";
import { IBbsArticle } from "@ORGANIZATION/PROJECT-api/lib/structures/bbs/IBbsArticle";
import { ArrayUtil } from "../../../../utils/ArrayUtil";
import { GaffComparator } from "../../../internal/GaffComparator";
import { RandomGenerator } from "../../../internal/RandomGenerator";
import { validate_index_sort } from "../../../internal/validate_index_sort";
export async function test_api_bbs_article_index_sort(
connection: api.IConnection,
): Promise {
// GENERATE 100 ARTICLES
const section: string = "general";
const articles: IBbsArticle[] = await ArrayUtil.asyncRepeat(100, () =>
api.functional.bbs.articles.store(connection, section, {
writer: RandomGenerator.name(),
title: RandomGenerator.paragraph(),
body: RandomGenerator.content(),
format: "txt",
files: [],
password: RandomGenerator.alphabets(8),
}),
);
typia.assertEquals(articles);
// PREPARE VALIDATOR
const validator = validate_index_sort("BbsArticleProvider.index()")(
(input: IBbsArticle.IRequest) =>
api.functional.bbs.articles.index(connection, section, input),
);
// DO VALIDATE
const components = [
validator("created_at")(GaffComparator.dates((x) => x.created_at)),
validator("updated_at")(GaffComparator.dates((x) => x.updated_at)),
validator("title")(GaffComparator.strings((x) => x.title)),
validator("writer")(GaffComparator.strings((x) => x.writer)),
validator(
"writer",
"title",
)(GaffComparator.strings((x) => [x.writer, x.title])),
];
for (const comp of components) {
await comp("+");
await comp("-");
}
}
```