Controller, Module, Provider(DI, IOC)개념을 아래 링크를 통해 익힐수 있다.
https://docs.nestjs.com/first-steps
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Rea
docs.nestjs.com
이후 코드 디자인 패턴도 익힐겸 아래 튜토리얼을 통해 validation을 적용해봤는데, 안되.... 출력이...
뭐지?? 싶었다.
https://dev.to/nandhakumar/nest-js-tutorial-2-http-request-data-validation-2bjn
Nest JS Tutorial #2: HTTP Request & Data Validation
Learn what is HTTP Request and how to validate the request data in Nest.JS
dev.to
공식 문서를 보니 validation은 class-validator을 통해 기능 구현이 가능한데, main.ts에 아래처럼 미들웨어를 추가해줘야 했다.
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({
origin: "http://localhost",
methods: "GET,HEAD,PUT,PATCH,POST,DELETE",
});
// validation 적용 미들웨어
app.useGlobalPipes(new ValidationPipe());
await app.listen(3000);
}
bootstrap();
이상입니다
*코드가 깨지면 아래 링크 참조해주세요
'개발 > typescript' 카테고리의 다른 글
[NestJs] 직관적으로 VO 생성하기 (0) | 2025.02.16 |
---|---|
[NestJs] Params, Query, Body (0) | 2023.06.28 |
[TS] Catch clause variable type annotation must be 'any' or 'unknown' if specified. (0) | 2022.07.21 |
[Typescript] Module '"react-router-dom"' has no exported member 'useHistory'. (0) | 2022.06.03 |
[Typescript] Object is of type 'unknown' (0) | 2022.06.02 |