<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Lery on Medium]]></title>
        <description><![CDATA[Stories by Lery on Medium]]></description>
        <link>https://medium.com/@coalery?source=rss-cf6eb572aa04------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gsLtfTnhzaf8CPhS</url>
            <title>Stories by Lery on Medium</title>
            <link>https://medium.com/@coalery?source=rss-cf6eb572aa04------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:37:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@coalery/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[NestJS v10 업데이트의 여정]]></title>
            <link>https://team.modusign.co.kr/nestjs-v10-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8%EC%9D%98-%EC%97%AC%EC%A0%95-fc0391a63fea?source=rss-cf6eb572aa04------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc0391a63fea</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[nestjs]]></category>
            <dc:creator><![CDATA[Lery]]></dc:creator>
            <pubDate>Thu, 23 Jan 2025 08:43:22 GMT</pubDate>
            <atom:updated>2025-03-10T15:51:47.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_qgezaJrVTZiyi2GPSiBZA.png" /></figure><p>안녕하세요, 모두싸인에서 백엔드를 개발하고 있는 러리입니다.</p><p>모두싸인은 NestJS 프레임워크를 기반으로 백엔드 시스템을 개발하고 있습니다. 하지만 제품 우선순위로 인해 업데이트가 계속 미뤄져, 여전히 오래된 6 버전대 NestJS를 사용하고 있었습니다.</p><p>구버전을 사용하면서 다른 최신 라이브러리와의 호환성 문제 등 여러 제약이 발생했고, 이를 해결하기 위해 추가한 여러 불필요한 로직들이 기술 부채로 쌓이고 있었습니다. 이러한 기술 부채들이 점점 기능 개발에 발목을 잡는 요소로 작용했기 때문에, 근본적인 해결을 위해 NestJS의 버전 업데이트를 진행했습니다.</p><p>물론 저 혼자서 진행하진 않았는데요. 모두싸인에서는 오랜 시간 쌓여온 기술 부채의 해소나 새로운 기술적 도전을 위해 여러 엔지니어가 자율적으로 모여 많은 시도를 할 수 있도록 엔지니어링 컬쳐 길드를 운영하고 있습니다.</p><p>이번 업데이트 역시 길드 활동을 통해 동료 엔지니어와 함께 진행했습니다. 이번 포스트에서는 모두싸인의 백엔드 서비스를 NestJS v10으로 업데이트하는 과정에서 만난 변경점들과 해결 방법을 소개해 드리려 합니다.</p><h3>변경점 소개</h3><p>시작하기에 앞서, 본 포스트는 NestJS의 모든 변경사항을 다루지는 않습니다. 메이저 버전이 4단계 올라가면서 수많은 변경 사항이 있었으므로, 이 글에 모든 걸 담기에는 어려움이 있었습니다. 따라서 업데이트를 하는 과정에서 저희가 겪은 변경점 중 주요하게 경험한 몇 가지를 중심으로 소개해 드리려 합니다. 이 점 참고 부탁드립니다.</p><h4><strong>createParamDecorator의 파라미터 변경</strong></h4><p>변경 버전: v6 → v7</p><pre>// Before<br>import { createParamDecorator } from &#39;@nestjs/common&#39;;<br><br>export const User = createParamDecorator((data, req) =&gt; {<br>  return req.user;<br>});</pre><pre>// After<br>import { createParamDecorator, ExecutionContext } from &#39;@nestjs/common&#39;;<br><br>export const User = createParamDecorator(<br>  (data: unknown, ctx: ExecutionContext) =&gt; {<br>    const request = ctx.switchToHttp().getRequest();<br>    return request.user;<br>  },<br>);</pre><p>기존에는 express의 Request처럼 기저에서 동작하는 라이브러리들의 객체가 파라미터로 들어왔으나, 마이크로서비스, 웹소켓 등의 환경에서 createParamDecorator를 사용할 수 있도록 요청 컨텍스트를 담고 있는 파라미터가 any 타입의 req에서 ExecutionContext로 변경되었습니다.</p><p>이를 통해 ExecutionContext에 담긴 컨텍스트에 따라 분기 처리하면 여러 실행 환경에 걸쳐 사용할 수 있는 데코레이터를 구현할 수 있습니다.</p><p>변경 사항 자체는 간단합니다만, 기존에도 req가 any 타입이었기 때문에 정적 타입 검사에서 잡아낼 수 없어 놓치기 쉽습니다.</p><pre>export const Requester = createParamDecorator((data, req): IRequester =&gt; {<br>  return req.requester;<br>});</pre><p>모두싸인에서는 대표적으로 @Requester 데코레이터를 구현할 때 createParamDecorator를 사용합니다. @Requester는 Guard에서 인증된 유저 정보를 Controller에서 쉽게 가져오기 위해 사용하고 있습니다.</p><p>하지만 단순히 위 예시처럼 간단하게는 수정할 수 없었는데요. 몇 가지 이유 때문에 저희는 @Requester를 <strong>두 버전을 동시에 호환할 수 있는 형태</strong>로 수정했습니다. 이에 대해서는 ”하위 호환 방법 소개” 파트에서 더 자세히 다뤄 볼 예정입니다.</p><h4>Terminus 모듈 변경</h4><p>변경 버전: v6 → v7</p><pre>// Before<br>@Injectable()<br>export class HealthCheckService implements TerminusOptionsFactory {<br>  constructor(<br>    private readonly keyValueStorage: KeyValueStorageHealthIndicator,<br>  ) {}<br>  createTerminusOptions(): TerminusModuleOptions {<br>    const healthEndpoint: TerminusEndpoint = {<br>      url: &#39;/health&#39;,<br>      healthIndicators: [async () =&gt; this.keyValueStorage.ping()],<br>    };<br>    return {<br>      endpoints: [healthEndpoint],<br>    };<br>  }<br>}<br>@Module({<br>  imports: [<br>    TerminusModule.forRootAsync({ useClass: HealthCheckService })<br>  ]<br>})<br>export class LifeCycleModule {}</pre><pre>// After<br>@Controller(&#39;/health&#39;)<br>export class HealthCheckController {<br>  constructor(<br>    private readonly healthCheckService: HealthCheckService,<br>    private readonly keyValueStorage: KeyValueStorageHealthIndicator,<br>  ) {}<br>  @Get()<br>  @HealthCheck()<br>  async checkHealth() {<br>    return this.healthCheckService.check([() =&gt; this.keyValueStorage.ping()]);<br>  }<br>}<br><br>@Module({<br>  imports: [TerminusModule],<br>  controllers: [HealthCheckController],<br>})<br>export class LifeCycleModule {}</pre><p>Health check API를 Swagger에서 나타내기 위해 기존에는 Service로 처리되던 Health check가 Controller로 구현하도록 변경되었습니다.</p><p>또, @nestjs/terminus의 peer dependency였던 @godaddy/terminus가 제거되었습니다. 이에 따라, 별도로 Health indicator를 구현하셨다면 HealthCheckError를 @godaddy/terminus 대신 @nestjs/terminus에서 가져오도록 변경해야 합니다.</p><h4>HttpException.message 타입 변경</h4><p>변경 버전: v6 → v7</p><pre>const exception = new NotFoundException(&#39;User not found&#39;);<br>console.log(JSON.stringify(exception));<br>/*<br>{<br>  &quot;response&quot;: {<br>    &quot;statusCode&quot;: 404,<br>    &quot;error&quot;: &quot;Not Found&quot;,<br>    &quot;message&quot;: &quot;User not found&quot;<br>  },<br>  &quot;status&quot;: 404,<br>  &quot;message&quot;: {<br>    &quot;statusCode&quot;: 404,<br>    &quot;error&quot;: &quot;Not Found&quot;,<br>    &quot;message&quot;: &quot;User not found&quot;<br>  }<br>}<br>*/</pre><p>NestJS v6에서 HttpException의 message 프로퍼티는 any 타입이며, 위 예시에서 볼 수 있듯이 NestJS에서 제공되는 빌트인 예외들은 모두 message 프로퍼티에 객체를 넣고 있었습니다.</p><pre>const exception = new NotFoundException(&#39;User not found&#39;);<br>console.log(JSON.stringify(exception));<br>/*<br>{<br>  &quot;response&quot;: {<br>    &quot;message&quot;: &quot;User not found&quot;,<br>    &quot;error&quot;: &quot;Not Found&quot;,<br>    &quot;statusCode&quot;: 404<br>  },<br>  &quot;status&quot;: 404,<br>  &quot;options&quot;: {},<br>  &quot;message&quot;: &quot;User not found&quot;,<br>  &quot;name&quot;: &quot;NotFoundException&quot;<br>}<br>*/</pre><p>이 부분이 NestJS v7부터는 message 프로퍼티의 타입이 string으로 변경되면서 간단하게 메시지를 가져올 수 있도록 변경되었습니다.</p><pre>// Before<br>getInnerObject(exception: HttpException) {<br>  if (exception.message instanceof Object) {<br>    return this.getInnerObject(exception.message);<br>  } else {<br>    return exception;<br>  }<br>}<br><br>let exception: HttpException;<br>if (error instanceof HttpException) {<br>  exception = error;<br>} else {<br>  exception = new InternalServerErrorException();<br>}<br>const errorObject = this.getInnerObject(exception);<br>const message = errorObject.message || errorObject.error;</pre><pre>// After<br>const message = error.message;</pre><p>이러한 변경 덕분에, 코드 베이스 곳곳에 존재했던 실제 메시지를 가져오기 위해 위와 같이 복잡한 메시지 파싱 로직이나 exception.message.message 같은 기형적인 코드를 모두 제거할 수 있었습니다.</p><h4>생성자 토큰과 문자열 토큰의 분리</h4><p>변경 버전: v7 → v8</p><pre>@Module({ providers: [AppService] })<br>export class AppModule {}<br><br>const app = await NestFactory.create(AppModule);<br>const isSame = app.get(AppService) === app.get(&#39;AppService&#39;);<br>console.log(isSame); // true or false</pre><p>NestJS는 v7까지 생성자 토큰과 문자열 토큰을 구분되지 않았습니다. 그래서 위와 같은 코드를 실행하면 true가 출력됩니다. 하지만, NestJS v8부터 둘을 구분하기 시작했습니다. 즉, 위 코드를 NestJS v8 이상 버전에서 실행하면 false가 출력됩니다.</p><p>이게 왜 문제가 될까요?</p><p>프로바이더를 모듈에 등록할 때 사용한 토큰과 주입할 때 사용한 토큰이 같다면, 위 변경 사항은 큰 문제가 되지 않습니다. 하지만 모두싸인에서는 프로바이더를 모듈에 등록할 때와 주입할 때, 생성자 토큰과 문자열 토큰을 혼용하고 있었습니다.</p><p>과거에 션이 <a href="https://team.modusign.co.kr/%EB%AA%A8%EB%91%90%EC%8B%B8%EC%9D%B8-%EB%B0%B1%EC%97%94%EB%93%9C-%EC%95%84%ED%82%A4%ED%85%8D%EC%B2%98-%ED%95%B4%EB%B6%80%ED%95%98%EA%B8%B0-a24aeccebd2a">모두싸인의 백엔드 아키텍처</a>를 소개 드린 적이 있었는데요. 모두싸인의 백엔드 아키텍처는 계층형 구조를 갖고 있고, 의존 역전 원칙(DIP)를 지키기 위해 도메인 정책이 존재하는 상위 레이어는 세부 사항을 구현한 하위 레이어에 직접 의존할 수 없습니다. 이 규칙은 모두싸인 백엔드 아키텍처의 중요한 원칙 중 하나로, 이를 유지하기 위해 dependency-crusier와 같은 도구를 활용해 관리하고 있습니다.</p><pre>@Module({ providers: [SomeService, SomeRepository] })<br>export class AppModule {}<br><br>@Injectable()<br>export class SomeRepository implements ISomeRepository { /* ... */ }<br><br>@Injectable()<br>export class SomeService {<br>  constructor(<br>    // v6에서는 `SomeRepository` 구현체가 주입됨<br>    @Inject(&#39;SomeRepository&#39;) private readonly repo: ISomeRepository<br>  ) {}<br>}</pre><p>이러한 구조에서 상위 레이어가 하위 레이어를 <strong>직접적인 의존 없이 호출할 수 있도록</strong> 문자열 토큰을 활용했었는데요. 상위 레이어에 인터페이스를 정의하고, 하위 레이어에서 이를 만족하는 구현체를 작성한 다음, 문자열 토큰을 통해 하위 레이어의 구현체를 주입받는 형태로 구성되어 있었습니다.</p><p>즉, 구현체 자체를 가져오는 것이 아니라 구현체의 이름을 통해 주입받고 있었지만, NestJS v10으로 업데이트하면서 문자열 토큰과 생성자 토큰이 분리되어 <strong>위와 같은 방법이 불가능</strong>해졌습니다.</p><p>이를 해결하기 위해서는 <strong>상위 계층에서 하위 계층을 직접 의존</strong>하거나, 프로바이더를 모듈에 등록할 때 프로바이더의 토큰을 <strong>문자열 토큰으로 명시해 주어야 합니다.</strong> 그러나 전자의 방법은 DIP를 위배하므로 선택할 수 없기 때문에, 결국 방법은 하나밖에 없었습니다.</p><p>하지만, 단순하게 모든 코드를 일일이 수정하는 것은 현실적으로 어려운 일입니다. NestJS 구현된 서비스의 수가 적지 않을 뿐 아니라, 각 서비스에 존재하는 수많은 코드를 하나하나 다 바꿔주어야 하기 때문입니다. 더군다나, 이를 처리할 리소스도 부족한 상황이었습니다.</p><p>따라서, 세부 구현은 최대한 건들지 않으면서도 적은 리소스로 빠르게 마이그레이션 하기 위해 providerMapper라는 함수를 정의하여 사용했습니다.</p><pre>export function providerMapper(providers: Provider[]): Provider[] {<br>  return providers.map((provider) =&gt; {<br>    if ((provider as Exclude&lt;Provider, Type&gt;).provide) {<br>      return provider;<br>    } else {<br>      return {<br>        provide: (provider as Extract&lt;Provider, Type&gt;).name,<br>        useClass: provider as Type&lt;any&gt;,<br>      };<br>    }<br>  });<br>}</pre><p>NestJS는 생성자 프로바이더, 클래스 프로바이더 외에도 여러 프로바이더를 제공하고 있습니다. 그중 생성자 프로바이더를 제외한 모든 프로바이더는 provide 프로퍼티를 갖는 객체의 형태를 띠고 있으므로, provide를 갖고 있지 않는, 즉 생성자 프로바이더를 모두 <strong>자신의 이름을 토큰으로 갖는 클래스 프로바이더로 매핑</strong>합니다.</p><pre>@Module({<br>  // ...<br>  providers: providerMapper([<br>    ...adapters,<br>    ...queries,<br>    ...mappers,<br>    // ...<br>  ]),<br>})<br>export class UserModule { /* ... */  }</pre><p>providerMapper를 활용하면 위와 같이 간단한 코드 수정으로도 기존 토큰을 호환할 수 있게 됩니다.</p><p>하지만, 장점만 존재하지는 않았는데요. 기존에는 문자열 토큰과 생성자 토큰을 혼용해서 사용할 수 있어, 같은 계층에서는 토큰 없이 사용하는 등 여러 방법을 통해 주입을 받을 수 있었으나, 위 변화로 인해 모든 프로바이더는 <strong>문자열 토큰으로만 주입받을 수 있는 문제</strong>가 있었습니다.</p><p>그러나, 기존에도 극히 일부를 제외하고는 모두 문자열 토큰을 사용하고 있었고, 어느 정도 암묵적인 컨벤션으로 동작하고 있었기 때문에 큰 문제가 되진 않을 것이라 판단하였습니다.</p><p>물론, 장기적으로 사용할 만한 방법은 아니므로 점점 제거해 나갈 예정입니다.</p><h3>하위 호환 방법 소개</h3><p>NestJS 업데이트를 시작하기에 앞서 해결해야 할 문제가 하나 있었습니다. 모두싸인에는 NestJS를 기반으로 한 백엔드 서비스의 코드 베이스뿐만 아니라, 인증, 인가, 로깅 등 횡단 관심사 관련 코드를 다루는 여러 사내 라이브러리들이 존재하는데요.</p><p>문제는, 각 라이브러리가 v10에서만 동작할 수 있도록 구현될 경우, 해당 라이브러리를 사용하는 서비스가 v10으로 업데이트되기 전까지는 라이브러리의 새로운 기능을 사용할 수 없다는 점입니다. 이로 인해 NestJS 업데이트가 기능 개발을 방해할 우려가 있었습니다.</p><p>따라서, <strong>모든 라이브러리를 v6과 v10을 동시에 호환</strong>할 수 있도록 먼저 코드를 수정한 다음, 서비스들을 차례대로 업데이트하기로 결정했습니다. 이를 위해 사용한 여러 방법을 소개 드리겠습니다.</p><h4>createParamDecorator</h4><p>앞에서 설명했던 @Requester 데코레이터는 공통 라이브러리에 포함되어 모두싸인의 많은 서비스에서 사용되고 있습니다. 따라서 createParamDecorator가 v6, v10 인터페이스 모두에서 동작할 수 있도록 수정이 필요했습니다.</p><pre>export const Requester = createParamDecorator(<br>  (data: unknown, reqOrCtx: Request | ExecutionContext): IRequester =&gt; {<br>    const req = &#39;switchToHttp&#39; in reqOrCtx<br>	      ? reqOrCtx.switchToHttp().getRequest&lt;Request&gt;() // v10인 경우<br>	      : reqOrCtx; // v6인 경우<br>    return req[&#39;requester&#39;];<br>  },<br>);</pre><p>NestJS v6에서는 reqOrCtx가 Request, NestJS v10에서는 ExecutionContext이기 때문에, ExecutionContext의 메서드인 switchToHttp 존재 여부에 따라 분기하여 처리하였습니다.</p><p>이를 통해 버전과 상관없이 요청자 정보를 가져올 수 있게 되었습니다.</p><h4>HttpException.message</h4><p>모두싸인에서는 에러 출력 처리를 위해 공통 라이브러리에서 ExceptionFilter를 선언해 관리하고 있습니다. 어플리케이션에서 발생하는 모든 에러는 ExceptionFilter에서 유저에게 출력할 때 사내 표준 에러 형태에 맞게 변환하는 과정을 거칩니다.</p><pre>interface HttpErrorResponse&lt;T&gt; {<br>  type: string;<br>  title: string;<br>  message: string;<br>  data?: T;<br>  detail?: string;<br>}</pre><p>이때, message에는 HttpException를 상속받은 Exception의 message를 주입하게 됩니다. 하지만, 앞에서 살펴본 것처럼 NestJS의 버전이 업데이트되면서 HttpException.message 필드가 Object에서 string 타입으로 변경되었습니다.</p><pre>this.message = exception.message instanceof Object<br>  ? (exception.message?.message as string)<br>  : (exception.message as string);</pre><p>따라서, 표준 에러의 message를 생성할 때, HttpException.messge의 타입에 따라 표준 에러 객체가 안전하게 만들어질 수 있도록 했습니다.</p><h4>useExisting</h4><p>NestJS 업데이트에서 가장 큰 난관은 바로 문자열 토큰과 생성자 토큰이 분리되는 부분이었습니다. 백엔드 서비스의 경우, 각 서비스 내에서만 토큰을 신경 써주면 되기 때문에 큰 문제가 없었습니다.</p><p>하지만 라이브러리의 경우, <strong>여러 서비스에 걸쳐 사용되다 보니</strong>, 문자열 토큰과 생성자 토큰이 동일한 인스턴스를 참조하도록 수정해야 했습니다.</p><p>즉, 아래 코드가 버전에 상관없이 항상 true가 될 수 있도록 수정해야 했습니다.</p><pre>// 그 외 코드는 적절하게 구현되어 있다고 가정합니다.<br>app.get(&#39;SomeService&#39;) === app.get(SomeService);</pre><p>이를 위해 여러 방법을 검토해 본 결과, NestJS의 <strong>ExistingProvider</strong>를 사용하기로 결정했습니다. ExistingProvider는 일종의 alias 역할을 하는 프로바이더로, 이미 IoC 컨테이너에 존재하는 프로바이더를 다른 토큰으로 가리킬 수 있게 해줍니다.</p><pre>@Module({<br>  providers: [<br>    SomeService,<br>    { provide: &#39;SomeToken&#39;, useExisting: SomeService }<br>  ]<br>})<br>export class AppModule {}<br><br>app.get(SomeService) === app.get(&#39;SomeToken&#39;) // true</pre><p>예를 들면, 위와 같이 모듈이 구성되었을 때 버전과 상관없이 SomeService와 &#39;SomeToken&#39;이 <strong>동일한 </strong><strong>SomeService 인스턴스를 참조</strong>합니다.</p><p>이 방법을 기반으로, 모듈을 사용하는 라이브러리에서 export 하는 모든 프로바이더는 문자열 토큰으로도 참조할 수 있고, 생성자 토큰으로도 참조할 수 있도록 수정하였습니다. 예를 들면 아래와 같습니다.</p><pre>const RequestStorageKey = Symbol(&#39;@nest-request-storage/RequestStorage&#39;);<br><br>@Module({<br>  providers: [<br>    { provide: RequestStorageKey, useClass: RequestStorage },<br>    { provide: RequestStorage, useExisting: RequestStorageKey },<br>    { provide: &#39;RequestStorage&#39;, useExisting: RequestStorageKey },<br>    // ...<br>  ],<br>  exports: [RequestStorage, &#39;RequestStorage&#39;],<br>})<br>export class RequestStorageModule { /* ... */ }</pre><p>실제 구현체를 참조하는 프로바이더는 Symbol 토큰으로 모듈에 등록하였고, 생성자 토큰과 문자열 토큰은 이 Symbol 토큰을 참조하도록 설정하여 동일한 RequestStorage 인스턴스를 참조할 수 있도록 구성하였습니다.</p><h3>하위 호환 테스트</h3><p>v6와 v10을 동시에 호환하기 위해 사용한 여러 방법을 소개 드렸는데요. 그렇다면 정말로 라이브러리들이 v6과 v10을 모두 호환한다는 것을 어떻게 보장할 수 있을까요?</p><p>물론 직접 테스트해 볼 수도 있겠지만, 이미 잘 작성된 견고한 테스트 코드가 있었기 때문에 이를 v6과 v10 환경 모두에서 활용하는 방법을 고민하게 되었습니다. 그러던 중, jest의 moduleNameMapper를 활용하는 방법을 찾아냈습니다.</p><pre>{<br>  &quot;moduleNameMapper&quot;: {<br>    &quot;^@nest-transaction$&quot;: &quot;&lt;rootDir&gt;/src&quot;,<br>    &quot;^@nest-transaction/(.*)$&quot;: &quot;&lt;rootDir&gt;/src/$1&quot;,<br>  }<br>}</pre><p>moduleNameMapper는 테스트를 실행하는 동안 특정 모듈을 다른 모듈로 모킹할 수 있는 기능을 제공합니다. 예를 들어, 위와 같이 설정하면 @nest-transaction/service는 실제로 src/service 위치에 있는 코드를 참조하게 됩니다.</p><p>이 원리를 NestJS 라이브러리에 동일하게 적용하면, 구현을 수정하지 않고도 테스트 실행 환경의 NestJS 버전을 유연하게 변경하며 테스트를 실행할 수 있습니다. 이를 통해 v6과 v10 모두에서 라이브러리가 정상적으로 동작하는지 쉽게 검증할 수 있습니다.</p><h4>테스트 환경 구성</h4><pre>// package.json<br>{<br>  &quot;devDependencies&quot;: {<br>    &quot;nestjs-common-v10&quot;: &quot;npm:@nestjs/common@^10.4.15&quot;,<br>    &quot;nestjs-common-v6&quot;: &quot;npm:@nestjs/common@^6.11.11&quot;,<br>    &quot;nestjs-core-v10&quot;: &quot;npm:@nestjs/core@^10.4.15&quot;,<br>    &quot;nestjs-core-v6&quot;: &quot;npm:@nestjs/core@^6.11.11&quot;,<br>    &quot;nestjs-testing-v10&quot;: &quot;npm:@nestjs/testing@^10.4.15&quot;,<br>    &quot;nestjs-testing-v6&quot;: &quot;npm:@nestjs/testing@^6.11.11&quot;,<br>  }<br>}</pre><p>먼저 테스트 대상인 v6과 v10의 NestJS 라이브러리를 npm alias를 사용하여 각각 서로 다른 이름으로 설치합니다.</p><pre>// jest.config.nestjs-v6.json<br>{<br>  &quot;moduleNameMapper&quot;: {<br>    &quot;^@nest-transaction$&quot;: &quot;&lt;rootDir&gt;/src&quot;,<br>    &quot;^@nest-transaction/(.*)$&quot;: &quot;&lt;rootDir&gt;/src/$1&quot;,<br>    &quot;^@nestjs/common$&quot;: &quot;nestjs-common-v6&quot;,<br>    &quot;^@nestjs/common/(.*)$&quot;: &quot;nestjs-common-v6/$1&quot;,<br>    &quot;^@nestjs/core$&quot;: &quot;nestjs-core-v6&quot;,<br>    &quot;^@nestjs/core/(.*)$&quot;: &quot;nestjs-core-v6/$1&quot;,<br>    &quot;^@nestjs/testing$&quot;: &quot;nestjs-testing-v6&quot;,<br>    &quot;^@nestjs/testing/(.*)$&quot;: &quot;nestjs-testing-v6/$1&quot;<br>  }<br>}</pre><p>그런 다음 각 버전 별로 적절한 NestJS 라이브러리가 매핑 되도록 jest config 파일에 moduleNameMapper를 구성합니다. 예를 들어, v6 용 설정은 위와 같이 구성하며 v10도 동일한 방식으로 만들어 줍니다.</p><pre>// package.json<br>{<br>  &quot;scripts&quot;: {<br>    &quot;test&quot;: &quot;npm run test:v6 &amp;&amp; npm run test:v10&quot;,<br>    &quot;test:v6&quot;: &quot;jest --config jest.config.nestjs-v6.json&quot;,<br>    &quot;test:v10&quot;: &quot;jest --config jest.config.nestjs-v10.json&quot;  <br>  }<br>}</pre><p>마지막으로 버전별로 테스트를 실행할 수 있도록 package.json의 테스트 스크립트를 수정해 주면, 구현을 수정하지 않고도 여러 버전의 NestJS를 테스트할 수 있게 됩니다.</p><h3>마치며</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sat4HT_v9JBwW4-YO-hi-w.png" /></figure><p>모두싸인의 모든 백엔드 서비스와 라이브러리들은 이제 NestJS v10 기반으로 운영되고 있습니다.</p><p>업데이트 과정에서 가장 중요한 목표는 백엔드 엔지니어들의 기존 개발 경험을 최대한 유지하는 것이었습니다. 업데이트도 물론 중요하지만, 업데이트 때문에 모든 기능 개발을 완전히 막아버릴 순 없었기 때문입니다. 이를 위해 서비스의 기존 구현을 최소한으로 변경하면서 안정적으로 버전을 업데이트할 방법을 고민했습니다. 또한, NestJS v10 업데이트 과정에서 변경된 사항들에 대한 가이드 문서를 작성하고 배포하여 사내 엔지니어 분들이 빠르게 적응할 수 있도록 노력했습니다.</p><p>NestJS 업데이트를 위한 엔지니어링 길드는 이제 그 임무를 마치고 사라지지만, 여전히 다양한 길드에서 많은 기술적 도전을 진행하고 있습니다. 이러한 도전은 모두싸인이 유저에게 높은 품질의 서비스를 제공하기 위한 밑바탕이 되고 있습니다.</p><p>모두싸인에서는 이러한 활동을 함께하실 분들을 기다리고 있습니다. 관심 있으신 분들은 적극 지원 부탁드립니다!</p><p><strong>▶ </strong><a href="https://recruit.modusign.co.kr/"><strong>모두싸인 채용공고 보러가기</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc0391a63fea" width="1" height="1" alt=""><hr><p><a href="https://team.modusign.co.kr/nestjs-v10-%EC%97%85%EB%8D%B0%EC%9D%B4%ED%8A%B8%EC%9D%98-%EC%97%AC%EC%A0%95-fc0391a63fea">NestJS v10 업데이트의 여정</a> was originally published in <a href="https://team.modusign.co.kr/">모두싸인 기술블로그</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>