[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요., 강의 잘 보고있습니다. 가드랑 미들웨어 용도를 이렇게 이해하면 좋을까요? 1.가드: -특정 컨트롤러로 들어온 파라매터, 혹은 context데이터를 가공하거나 검증하고 싶을때 2.미들웨어: -특정 규칙을 가진 패쓰 혹은 컨트롤러 전체에 데이터를 검증하고 싶을때 아주 맨 처음에 저는 token 을 검증하는 BearerTokenGuard이 가드보다는 middleware 로 가는것이 맞지 않나 싶었는데요. context.user 데이터를 controller 에 내려주기 위해 IsCommentMine Guard 처럼 다른 가드로 유저데이터를 넘겨줘야하는 경우가 있어서 가드로 사용하는것으로 이해했는데 맞을까요? (그리고 middleware 로는 불가능한걸까요?)
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요. update comment 관련 두가지 질문이 있습니다. update(patch) 에서는 query runner를사용하지 않아도 되나요? update 시에repository.update 가 아닌 save 를 사용한 이유가 있을까요? 항상 강의 잘 보고있습니다. 감사합니다!
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요. 섹션5의 Post 요청 만들기 영상을 보다가 궁금증이 생겨 질문드립니다. Q1) 새로운 post 생성시 id를 부여할 때 배열의 마지막 인덱스 아이템을 꺼내 해당 아이템의 id에 1을 더하셨습니다. 그런데 배열 안의 아이템 순서가 꼭 id-오름차순으로 정렬되어있을거란 보장이 없기 때문에 배열에서 가장 큰 id를 찾은 후, +1을 하여 새로운 id를 부여해줘야하지 않을까 싶은데 제가 잘못 생각하고 있는걸까요? Q2) 새로운 post를 기존 배열에 push하지 않고, spread 방식으로 추가해주셨는데 특별한 이유가 있는건지도 궁금합니다!
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
https://docs.nestjs.com/faq/request-lifecycle 공식 문서에 보니까 controller level에서 사용 할 수 있는것 같아서 controller와 gateway가 비슷하니까 사용 가능하지 않을까 해서 테스트 해보니까 @UsePipes( new ValidationPipe({ transform: true, transformOptions: { enableImplicitConversion: true, }, whitelist: true, forbidNonWhitelisted: true, }), ) @WebSocketGateway({ // ws://localhost:3000/chats namespace: 'chats', }) export class ChatsGateway implements OnGatewayConnection { ... } 해당 gateway에서 usePipes를 설정 할 수 있더라고요! 차선책으로 이것도 괜찮은것 같아서 공유 해봅니다!
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
아마 강사님 실수인듯합니다. User 1이 enter_room에 2번 채팅방에 참여 한다고 메세지를 보내는데 "enter_chat"이 맞습니다! 제가 실험 해보니까 결국 enter_chat을 제대로 하지 않은 경우에 다른 사용자가 보낸 message를 제대로 리시브 받지 못하더라고요.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요 쿼리러너 관련 질문드립니다 코멘트 생성시 Pid 에 일부러 엉뚱한 값을 넣는 경우 QueryRunner를 쓰고 안쓰고에 차이가 있더라구요. 예를들어 this.commentService.ceateComment(dto, pId, user, qr); qr repository 를 일부러 사용하지 않게 조작하면 pid 에 이상한 값을 넣어도 valitation 없이 create 가 되었는데 Qr 을 넘겨주는 순간 아래와 같이 유효하지 않은 pk 에 대해 조작하려고 한다는 validation 을 해주더라구요. { "path": "/posts/{엉뚱한 값}/comments", "statusCode": 500, "message": "insert or update on table \"comment\" violates foreign key constraint \"FK_94a85bb16d24033a2afdd5df060\"", "timestamp": "1/21/2024, 4:06:08 PM" } 이런 차이는 어디서 나는것일지, 이런것들도 Query Runner 의 역할인지도 궁금합니다.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
length에서 max값을 전달 안해주고 min만 설정하고 싶을때 if(args.constraints.length===2){ } else}{ } 여기서 else 가 실행되어야 하는데 max 값 없이 validationOptions만을 전달하면 validationOptions가 두번째 인자로 전달되는 것 아닌가요..? 이렇게 하면 에러 나는데.. max 값에 undefined나 null을 넣어도 안되는 것 같습니다. 어떻게 max 값 없이 validationOptions를 실행할 수 있나요..?
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요. 강의 보면서 docker-compose 파일 만들고 실행하다가 막히는 부분이 있어 질문드립니다. os ubuntu 20.04 docker version Docker version 24.0.2, build cb74dfc docker-compose file services: postgres: image: postgres:15 restart: always volumes: - ./postgres-data:/var/lib/postgresql/data ports: - '5432:5432' environment: POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres POSTGRES_DB: postgres terminal log [+] Running 1/0 ✔ Container nestjs_sns_server-postgres-1 Created 0.0s Attaching to nestjs_sns_server-postgres-1 nestjs_sns_server-postgres-1 | The files belonging to this database system will be owned by user "postgres". nestjs_sns_server-postgres-1 | This user must also own the server process. nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | The database cluster will be initialized with locale "en_US.utf8". nestjs_sns_server-postgres-1 | The default database encoding has accordingly been set to "UTF8". nestjs_sns_server-postgres-1 | The default text search configuration will be set to "english". nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | Data page checksums are disabled. nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | fixing permissions on existing directory /var/lib/postgresql/data ... ok nestjs_sns_server-postgres-1 | creating subdirectories ... ok nestjs_sns_server-postgres-1 | selecting dynamic shared memory implementation ... posix nestjs_sns_server-postgres-1 | selecting default max_connections ... 100 nestjs_sns_server-postgres-1 | selecting default shared_buffers ... 128MB nestjs_sns_server-postgres-1 | selecting default time zone ... Etc/UTC nestjs_sns_server-postgres-1 | creating configuration files ... ok nestjs_sns_server-postgres-1 | running bootstrap script ... ok nestjs_sns_server-postgres-1 | performing post-bootstrap initialization ... ok nestjs_sns_server-postgres-1 | syncing data to disk ... ok nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | Success. You can now start the database server using: nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | pg_ctl -D /var/lib/postgresql/data -l logfile start nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | initdb: warning: enabling "trust" authentication for local connections nestjs_sns_server-postgres-1 | initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb. nestjs_sns_server-postgres-1 | waiting for server to start....2024-01-17 13:05:30.755 UTC [49] LOG: starting PostgreSQL 15.5 (Debian 15.5-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit nestjs_sns_server-postgres-1 | 2024-01-17 13:05:30.760 UTC [49] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" nestjs_sns_server-postgres-1 | 2024-01-17 13:05:30.777 UTC [52] LOG: database system was shut down at 2024-01-17 13:05:30 UTC nestjs_sns_server-postgres-1 | 2024-01-17 13:05:30.786 UTC [49] LOG: database system is ready to accept connections nestjs_sns_server-postgres-1 | done nestjs_sns_server-postgres-1 | server started ... nestjs_sns_server-postgres-1 | nestjs_sns_server-postgres-1 | 2024-01-17 13:30:30.440 UTC [1] LOG: starting PostgreSQL 15.5 (Debian 15.5-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit nestjs_sns_server-postgres-1 | 2024-01-17 13:30:30.440 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432 nestjs_sns_server-postgres-1 | 2024-01-17 13:30:30.440 UTC [1] LOG: listening on IPv6 address "::", port 5432 nestjs_sns_server-postgres-1 | 2024-01-17 13:30:30.450 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432" nestjs_sns_server-postgres-1 | 2024-01-17 13:30:30.463 UTC [29] LOG: database system was shut down at 2024-01-17 13:30:21 UTC nestjs_sns_server-postgres-1 | 2024-01-17 13:30:30.473 UTC [1] LOG: database system is ready to accept connections nestjs_sns_server-postgres-1 | 2024-01-17 13:30:33.019 UTC [1] LOG: received fast shutdown request nestjs_sns_server-postgres-1 | 2024-01-17 13:30:33.024 UTC [1] LOG: aborting any active transactions nestjs_sns_server-postgres-1 | 2024-01-17 13:30:33.025 UTC [1] LOG: background worker "logical replication launcher" (PID 32) exited with exit code 1 nestjs_sns_server-postgres-1 | 2024-01-17 13:30:33.025 UTC [27] LOG: shutting down nestjs_sns_server-postgres-1 | 2024-01-17 13:30:33.030 UTC [27] LOG: checkpoint starting: shutdown immediate nestjs_sns_server-postgres-1 | 2024-01-17 13:30:33.063 UTC [27] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.011 s, sync=0.005 s, total=0.038 s; sync files=2, longest=0.003 s, average=0.003 s; distance=0 kB, estimate=0 kB nestjs_sns_server-postgres-1 | 2024-01-17 13:30:33.069 UTC [1] LOG: database system is shut down (1만자 이하로 작성해야 해서 로그는 중간 생략하였습니다.) docker-comopse 파일이 정상적으로 실행이 되고 있는 상황인데 Postgresql 데이터 베이스 연결하면서 문제가 발생하고 있는것 같습니다. 프로젝트 폴더의 postgres-data 폴더에도 postgresql 데이터가 생성되지 않았구요. 혹시 제가 잘못하고 있는 부분이 있을까요..?
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
저 명령어로 posts을 만들고 나서 파일을 삭제하였다가 다시 posts를 만들고 서버를 실행하였는데 사진과 같은 오류가 생겼습니다. app.module.ts 파일에는 저런 코드가 없는데 왜 그런지 알려주세요. 그리고 올바르게 posts리소스를 삭제하는 방법을 알려주세요.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요. 코드팩토리 통합 링크 https://links.codefactory.ai Flutter 강의를 구매하시면 코드팩토리 디스코드 서버 플러터 프리미엄 채널에 들어오실 수 있습니다! 디스코드 서버에 들어오시고 저에게 메세지로 강의를 구매하신 이메일을 보내주시면 프리미엄 채널에 등록해드려요! 프리미엄 채널에 들어오시면 모든 질의응답 최우선으로 답변해드립니다! 안녕하세요! 공부하다 궁금해서요 post도 추가할 수 있고 결국 put도 추가할 수 있는데 그럼 post랑 put의 차이점은 명확하게 뭘까요?
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요. 섹션 7. 의존성 주입과 제어의 역전에 대해 보고 있습니다. 해당 부분을 보다가 의문점이 생겼습니다. 만약 B라는 클래스가 동시에 두군데에서 필요하다면 Ioc 컨테이너는 B 인스턴스를 두개를 생성해서 주입하나요? 아니면, 인스턴스는 무조건 하나만 생성하여 참조값으로 주입하는 건가요? 답변해주시면 감사하겠습니다.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요. storage코드 작성 후 diskStorage관련하여 TypeError가 발생하였습니다. 강의 내용과 동일하게 작성을 하였는데 빌드 시 해당에러가 발생하고 diskStorage의 인자에 아무것도 넣지 않아도 동일한 에러가 발생하는데 원인이 무엇인지 알 수가 없어서 글을 올립니다. module 코드입니다. error_msg코드입니다.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
강의 완강하고 요즘 연습하면서 한 가지 궁금증이 생겨서 질문드립니다. websocket 사용 용도가 실시간 커뮤니케이션이라고 알고 있는데요 인스타그램으로 예를 들면 다른 사람을 팔로우하면 바로 팔로우 카운트가 실시간으로 올라가는 거랑 유튜브에 댓글들이 실시간으로 생기는 방식들이 전부 webscoket으로 구현하는 게 맞나요?? 인스타처럼 상대방을 팔로우하면 제 팔로잉 카운트가 증가하는 동시에 상대방의 팔로워 카운트가 증가하는 로직을 만들었는데 곰곰이 생각해 보니 팔로우 카운트 증가는 제가 어떠한 http요청 없이 실시간으로 올라가고 내려가는데, 일반적인 api로직을 만드는 방식으로 하는 게 맞나 하는 의문이 생겨서 질문드렸습니다~