코딩/Nest.js 9

Swagger

- Swagger란 간단히 말해 RestAPI에 대한 설명과 테스트를 해볼 수 있는 사이트를 만드는 것이다. - 설치yarn add @nestjs/swagger  - 세팅main.ts에 swagger에 대한 코드를 작성해야하는데 그러면 main.ts가 지저분해지므로setupSwagger.ts 라는 파일을 만들고 안에import { INestApplication } from '@nestjs/common';import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';export function setupSwagger(app: INestApplication): void { const config = new DocumentBuilder() .setT..

코딩/Nest.js 2024.04.24

Global Pipes

- 설치 yarn add class-validator class-transformer - main.ts에 GlobalPipes 설정 app.useGlobalPipes(new ValidationPipe()); ++ dto 제약/필터 걸기 // 이렇게 dto 같은거에 제약/필터 걸 수 있음. // 영어로 응답이 가고, 해당 키의 값으로 알리다보니 front에서 바로 쓰기에는 제약이 있음.. export class TestInput { @IsNotEmpty() user_id: string; } ++ 추가적인 공부 필요함. https://docs.nestjs.com/faq/request-lifecycle Documentation | NestJS - A progressive Node.js framework Nes..

코딩/Nest.js 2024.04.22

환경변수 ConfigModule

- 설치 yarn add @nestjs/config - import ConfigModule.forRoot(), - 환경변수 위치를 지정하거나, 다른 모듈에서도 사용할 수 있도록 글로벌 설정할 경우 ConfigModule.forRoot({ isGlobal: true, envFilePath: './env/.dev.env', }), https://docs.nestjs.com/techniques/configuration#custom-env-file-path Documentation | NestJS - A progressive Node.js framework Nest is a framework for building efficient, scalable Node.js server-side applications. ..

코딩/Nest.js 2024.04.22

오류 상태 코드

BadRequestException: 클라이언트의 요청이 서버에게 잘못된 요청이거나 부적절한 경우 발생합니다. UnauthorizedException: 클라이언트가 인증되지 않은 경우 또는 인증 정보가 유효하지 않은 경우 발생합니다. NotFoundException: 요청한 리소스를 찾을 수 없는 경우 발생합니다. ForbiddenException: 클라이언트가 리소스에 액세스할 권한이 없는 경우 발생합니다. NotAcceptableException: 서버가 클라이언트의 요청에 대한 응답을 제공할 수 없는 경우 발생합니다. RequestTimeoutException: 클라이언트의 요청이 서버에서 처리되기까지 시간이 너무 오래 걸리는 경우 발생합니다. ConflictException: 클라이언트의 요청이 ..

코딩/Nest.js 2024.04.20