スキル一覧に戻る
doanchienthangdev

building-nestjs-apis

by doanchienthangdev

Omega Vibecode Kit

2🍴 1📅 2026年1月21日
GitHubで見るManusで実行

SKILL.md


name: building-nestjs-apis description: Builds enterprise NestJS applications with TypeScript, dependency injection, TypeORM, and microservices patterns. Use when creating scalable Node.js backends, REST/GraphQL APIs, or microservices.

NestJS

Quick Start

import { Controller, Get, Module, NestFactory } from '@nestjs/common';

@Controller('health')
class HealthController {
  @Get()
  check() {
    return { status: 'ok' };
  }
}

@Module({ controllers: [HealthController] })
class AppModule {}

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}
bootstrap();

Features

FeatureDescriptionGuide
ModulesDependency injection, providersMODULES.md
ControllersRoutes, validation, guardsCONTROLLERS.md
ServicesBusiness logic, repositoriesSERVICES.md
DatabaseTypeORM, Prisma integrationDATABASE.md
AuthPassport, JWT, guardsAUTH.md
TestingUnit, e2e with JestTESTING.md

Common Patterns

Controller with Validation

@Controller('users')
@UseGuards(JwtAuthGuard)
export class UsersController {
  constructor(private readonly usersService: UsersService) {}

  @Get()
  @Roles('admin')
  findAll(@Query() query: PaginationDto) {
    return this.usersService.findAll(query);
  }

  @Get(':id')
  findOne(@Param('id', ParseUUIDPipe) id: string) {
    return this.usersService.findOne(id);
  }

  @Post()
  create(@Body() dto: CreateUserDto) {
    return this.usersService.create(dto);
  }
}

Service with Repository

@Injectable()
export class UsersService {
  constructor(private readonly usersRepo: UsersRepository) {}

  async findAll(query: PaginationDto) {
    const [users, total] = await this.usersRepo.findAllWithCount({
      skip: query.skip,
      take: query.limit,
    });
    return { data: users, total, page: query.page };
  }

  async findOne(id: string) {
    const user = await this.usersRepo.findOne({ where: { id } });
    if (!user) throw new NotFoundException('User not found');
    return user;
  }

  async create(dto: CreateUserDto) {
    const exists = await this.usersRepo.findByEmail(dto.email);
    if (exists) throw new ConflictException('Email in use');
    return this.usersRepo.save(this.usersRepo.create(dto));
  }
}

DTO with Validation

export class CreateUserDto {
  @IsEmail()
  email: string;

  @IsString()
  @MinLength(2)
  name: string;

  @IsString()
  @MinLength(8)
  @Matches(/^(?=.*[A-Z])(?=.*\d)/, {
    message: 'Password must contain uppercase and number',
  })
  password: string;

  @IsOptional()
  @IsEnum(UserRole)
  role?: UserRole;
}

Workflows

API Development

  1. Create module with nest g module [name]
  2. Create controller and service
  3. Define DTOs with class-validator
  4. Add guards for auth/roles
  5. Write unit and e2e tests

Module Structure

@Module({
  imports: [TypeOrmModule.forFeature([User])],
  controllers: [UsersController],
  providers: [UsersService, UsersRepository],
  exports: [UsersService],
})
export class UsersModule {}

Best Practices

DoAvoid
Use dependency injectionDirect instantiation
Validate with DTOsTrusting input
Use guards for authAuth logic in controllers
Use interceptors for cross-cuttingDuplicating logging/transform
Write unit + e2e testsSkipping test coverage

Project Structure

src/
├── main.ts
├── app.module.ts
├── common/
│   ├── decorators/
│   ├── guards/
│   ├── interceptors/
│   └── pipes/
├── config/
├── users/
│   ├── users.module.ts
│   ├── users.controller.ts
│   ├── users.service.ts
│   ├── dto/
│   └── entities/
└── auth/
    ├── auth.module.ts
    ├── strategies/
    └── guards/

For detailed examples and patterns, see reference files above.

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です