본문 바로가기

전체 글

[Javascript] 표준 내장 객체 Object를 알아보자 Object() constructornew Object(), new Object(undefined), new Object(null) 은 빈 객체를 반환한다 // {} Object.assign()Object.assign(target, source); target에게 source를 덮어쓴다.const obj = { a: 1 };const copy = Object.assign({}, obj);console.log(copy); // { a: 1 }const o1 = { a: 1 };const o2 = { b: 2 };const o3 = { c: 3 };const obj = Object.assign(o1, o2, o3);console.log(obj); // { a: 1, b: 2, c: 3 }console.log.. 더보기
[NestJS] passport-jwt JWTStrategy 10 yarn add @nestjs/passport passport passport-jwt jsonwebtoken @types/jsonwebtoken jwtStragety 추가하고Guard 추가한 후, 적용할 controller나 method에 guard 적용import { FastifyRequest } from "fastify";import { PassportStrategy } from "@nestjs/passport";import { Injectable } from "@nestjs/common";import { Strategy as JwtStrategy, ExtractJwt, VerifiedCallback } from "passport-jwt";import { ConfigService } from "@ne.. 더보기
[NestJS]Swagger 설정 및 @UseInterceptors (ClassSerializerInterceptor) 적용하기 09 yarn add @nestjs/swagger @fastify/swagger @fastify/swagger-ui  setSwaggerMiddleware(app);function setSwaggerMiddleware(app: NestFastifyApplication) { const config = new DocumentBuilder() .setTitle("Nestjs Toy API DOCS") .setVersion("1.0") .addBearerAuth({ type: "http", scheme: "bearer", name: "JWT", in: "header" }) .build(); const document = SwaggerModule.createDocument(app, confi.. 더보기
[NestJS] Lifecycle global filter, pipes, exception 설정하기 08 nestjs 라이프사이클 설명: https://velog.io/@haron/NestJS-Lifecycle-Events yarn add underscore @types/underscore* underscore에서 omit 하려고 사용하는것인데, 필요없으면 안써도됨 middleware > Guard > Interceptor > Filter > Pipes > Custom Decotators 순서로 실행** nests/core 소스 확인하기 global 설정interceptor 2개 만들었음1. success 처리 (PUT, DELETE, PATCH 공통처리)2. logging 처리 (multipart에서 value는 지워서 출력) filter도 2개1. AllExceptionFilter2. Validation.. 더보기
[NestJS] nest-winston 사용하기 07 필요한 패키지 설치yarn add nest-winston winston winston-daily-rotate-file  winston-daily 옵션 만들고, winstonOption 만들고 nest-winston으로 WinstonModule화 하고 내장 logger에 설정하기import { WinstonModule, utilities } from "nest-winston";import * as winston from "winston";import * as winstonDaily from "winston-daily-rotate-file";const dailyOption = (level: string, module?: string) => { const dirname = module ? `./logs/${.. 더보기