Nest.js
-
TypeOrm을 사용할때 식별관계 테이블에서 find 메서드에 skip과 take 사용시 주의 해야할점Nest.js/TypeOrm 2024. 4. 10. 22:23
// repository await this.repository.find({ select: { id: true, notificationTitle: true, notificationFeedId: true, createdAt: true, }, where: { recipientId, }, relations: { sender: true, }, skip, take, }); 해당 쿼리가 대충 아래처럼 실행 될것이라고 예상 했지만 그렇지 않았다. FK를 가르키는 senderId를 찾을 수 없다는 에러가 나왔다. select fn."senderId", fn."id", fn."notificationTitle", fn."createdAt", fn."senderId", fn."notificationFeedId" from f..
-
NestJS에서 yarn-berry로 생성 후 발생하던 문제Nest.js 2024. 4. 7. 21:17
EsLint와 prettierrc를 적용 하면서 발생한 문제 by vscode 오류 메세지는 잃어 버렸으나 해결을 위해 설치 했던것들 $ yarn add -D typescript@~5.3.9 $ yarn add -D eslint-import-resolver-typescript $ yarn add -D eslint-plugin-import yarn에서 npm처럼 npm_modules를 날리고 다시 install 하고 싶을때 .yarn 폴더지우기 yarn.lock 지우기 $ yarn install // yarn install후에 꼭 설치 해주어야 vscode가 typescript를 찾을 수 있다 $ yarn dlx @yarnpkg/sdks vscode 아무 ts 파일에 간다음에 f1번 누르고 version이..
-
WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estreeNest.js 2024. 4. 7. 20:37
yarn-berry로 Nestjs 프로젝트를 만들었을때 eslint 명령어를 입력 했을때 발생하는 에러 WARNING: You are currently running a version of TypeScript which is not officially supported by @typescript-eslint/typescript-estree. You may find that it works just fine, or you may not. SUPPORTED TYPESCRIPT VERSIONS: >=4.3.5
-
jest에서 모킹함수 'toHaveBeenCalledWith' 의 이상한점Nest.js/TDD 2024. 3. 26. 17:24
https://jestjs.io/docs/expect#tohavebeencalledwitharg1-arg2- 특정 인수를 사용하여 모의 함수가 호출되었는지 확인하는 데 사용됩니다. test('registration applies correctly to orange La Croix', () => { const beverage = new LaCroix('orange'); register(beverage); const f = jest.fn(); applyToAll(f); expect(f).toHaveBeenCalledWith(beverage); }); 특정 인수를 모의함수가 호출되었는지 테스트 하는거라고 공식문서에 나와있는데, e2e테스트를 공부하던중에 이상한 버그가 있었다. it('(GET) check co..
-
e2e 테스트를 공부 하면서 save함수의 리턴값과 toEqual로 값비교Nest.js/TDD 2024. 3. 20. 21:44
mockData = await postsRepository.save({ id: 1, author: '타입스크립트', title: '타입스크립트', content: '타입스크립트', likeCount: 0, commentCount: 0, created_at: new Date(), updated_at: new Date(), }); it('(GET) get Post /posts/:postId', async () => { const res = await request(app.getHttpServer()) .get(`/posts/${mockData.id}`) .expect(HttpStatus.OK); expect(res.body).toEqual(mockData); }); 미리 생성된 post의 id로 get요청해..
-
왜 테스트 코드를 작성 해야 하는지 알게 된 경험(typeorm bigint 이슈)Nest.js/TDD 2024. 3. 19. 18:01
e2e 테스트 공부를 하고 있었는데 - posts.entity.ts import { Column, Entity, PrimaryColumn } from 'typeorm'; @Entity() export class PostsModel { @PrimaryColumn({ type: 'bigint' }) id: number; @Column() author: string; @Column() title: string; @Column() content: string; @Column() likeCount: number; @Column() commentCount: number; } - docker-compose.yaml services: postgres: image: postgres:15 restart: always vo..
-
NestJS redis 라이브러리Nest.js 2024. 3. 17. 16:33
https://www.npmjs.com/package/@liaoliaots/nestjs-redis @liaoliaots/nestjs-redis Redis(ioredis) module for Nest framework (node.js).. Latest version: 9.0.5, last published: a year ago. Start using @liaoliaots/nestjs-redis in your project by running `npm i @liaoliaots/nestjs-redis`. There are 41 other projects in the npm registry using www.npmjs.com https://www.npmjs.com/package/ioredis
-
NestJS에서 에러 로그 생성 및 관리Nest.js 2024. 3. 12. 15:28
https://velog.io/@inmyblue0930/winton-daily-rotate-file Winston + Winston-daily-rotate-file 를 이용하여 로그 파일 관리 Sentry-Slack 연동 | 실시간 로그모니터링 https://velog.io/@inmyblue0930/Sentry-Slack-%EC%97%B0%EB%8F%99-%EC%8B%A4%EC%8B%9C%EA%B0%84-%EB%A1%9C%EA%B7%B8%EB%AA%A8%EB%8B%88%ED%84%B0%EB%A7%81 [NestJs]Sentry-Slack 연동 | 실시간 로그모니터링 목표 1) Sentry를 통해 에러 발생시 바로 트래킹 2) Slack으로 에러 전송 설치해야할 라이브러리 Sentry 연결 > Sentry..