diff --git a/src/app.controller.spec.ts b/src/app.controller.spec.ts index d22f389..4ac71e3 100644 --- a/src/app.controller.spec.ts +++ b/src/app.controller.spec.ts @@ -1,22 +1 @@ -import { Test, TestingModule } from '@nestjs/testing'; -import { AppController } from './app.controller'; -import { AppService } from './app.service'; - -describe('AppController', () => { - let appController: AppController; - - beforeEach(async () => { - const app: TestingModule = await Test.createTestingModule({ - controllers: [AppController], - providers: [AppService], - }).compile(); - - appController = app.get(AppController); - }); - - describe('root', () => { - it('should return "Hello World!"', () => { - expect(appController.getHello()).toBe('Hello World!'); - }); - }); -}); +describe('AppController', () => {}); diff --git a/src/app.controller.ts b/src/app.controller.ts index cce879e..3833980 100644 --- a/src/app.controller.ts +++ b/src/app.controller.ts @@ -1,12 +1,34 @@ -import { Controller, Get } from '@nestjs/common'; +import { + Body, + ClassSerializerInterceptor, + Controller, + Get, + Post, + UseInterceptors, +} from '@nestjs/common'; import { AppService } from './app.service'; +import { ApiBody, ApiExtraModels, getSchemaPath } from '@nestjs/swagger'; +import { TrackingDto } from '@/dtos/tracking.dto'; @Controller() +@ApiExtraModels(TrackingDto) +@UseInterceptors(ClassSerializerInterceptor) export class AppController { constructor(private readonly appService: AppService) {} @Get() - getHello(): string { - return this.appService.getHello(); + debug(): unknown { + return this.appService.debug(); + } + + @Post() + @ApiBody({ + schema: { + $ref: getSchemaPath(TrackingDto), + }, + }) + test(@Body() body: TrackingDto): string { + console.log(body); + return 'ok'; } } diff --git a/src/app.service.ts b/src/app.service.ts index 927d7cc..2ec496c 100644 --- a/src/app.service.ts +++ b/src/app.service.ts @@ -1,8 +1,19 @@ import { Injectable } from '@nestjs/common'; +import { ContainerEntity } from '@/entities/container.entity'; +import { Repository } from 'typeorm'; +import { InjectRepository } from '@nestjs/typeorm'; @Injectable() export class AppService { - getHello(): string { - return 'Hello World!'; + constructor( + @InjectRepository(ContainerEntity) + private readonly containerRepository: Repository, + ) {} + async debug(): Promise { + return this.containerRepository.find({ + take: 5, + }); + + // return 'Hello World!'; } }