본문 바로가기

728x90

Nest js

(22)
typeorm relation 관계에서 오류 문제는 아래와 같다 @Entity()export class Deal extends CoreEntity { @Column({nullable:true}) compa_name:string; @Column({nullable: true}) compaBrand_ImgURL:string; @Column({nullable:true}) salesManager_mobilephone:string; @Length(3) @ManyToOne( () => Member, member => member.deal, ) seller: Member; @RelationId((deal:Deal) => deal.seller) sellerId: number; @Column({nullable: true}) sel..
WebRTC의 이해 WebRTC란? Web Real Time Communication의 약자이고 오픈 소스 프로젝트이며 WebRTC를 사용하면 PlugIn 또는 Framework 없이 웹을 통해 모든 종류의 비디오, 오디오, 데이터를 교환할 수 있다. WebRTC API WebRTC는 3가지 Javascript API 를 사용 MediaStream: getUserMedia라고 불린다. 이 interface는 오디오 및 비디오 트랙을 포함할 수 있는 장치의 media stream을 나타낸다. MediaDevices.getUserMedia() 메서드는 MediaStream을 검색한다. RTCPeerConnection: 피어 간의 통신을 허용한다. MediaDevices.getUserMedia()에 의해 접근되는 stream이 ..
Nest can't resolve dependencies of the DealService NestJS 프레임워크에서 자주 볼 수 있는 에러가 참조 에러이다. 실제 아래의 에러가 발생하면 어떤 조치를 취하면 될까? 1. 원인 If "MemberRepository" is a provider, is it part of the current DealModule? 여기서 추론 할 수있는게 바로 MemberRepsoitory를 프로바이더 이면 DealModule의 부분이냐? 이 Nestjs 프레임워크에 적응이 되어있지 않으면 이해가 조금 난해하고 헤매기 쉽다. 이 의미는 DealModule에 등록을 하고 MemberRepository를 주입해라 이런 의미다. [deal.service.ts파일] 여기에서 MemberRepository를 주입해서 사용하고 있는데! @Injectable() export cl..
DataTypeNotSupportedError 1. 에러 발생 에러가 나는 이유는 ? OrderItem 엔티티와 Robot 엔티티와의 관계 설정을 하지 않아서 발생했다. 2. 에러 발생 시점 코드 OrderItem Entity import { CoreEntity } from 'src/common/entites/core.entity'; import { Robot } from 'src/deals/entitles/robot.entity'; import { Column, Entity, ManyToOne } from 'typeorm'; export class RobotOption { maintenanceYN:boolean; maintenance_cost: number; } @Entity() export class OrderItem extends CoreEnt..
NestJS @Query 고객이 리퀘스트를 보내면 파라미터를 같이 보내는 경우를 실습하자! 1. GET 요청 http://localhost:3000/admin/search?name=mansour 이렇다고 가정 그렇다면 NestJS는 어떻게 파라미터를 받을까 ? 2. @Query의 사용을 통해 name 변수에서 받을 수 있다. @Controller('admin') export class AdminController { constructor(private adminService: AdminService) { this.adminService = adminService; } @Get('/members/search') searchMember(@Query('name') name: string) { return this.adminServic..
class-validator class-validator란 ? " typescript를 사용하여 데코레이터로 검증한다! " 너무 간단하게 이야기 했나? 짧고 시원하게 이해가 가도록 설명하겠다! 첫 번째 이해 방법: POST 요청의 라우터 핸들러가 있고 @Param 또는 @Body 여기에서 JSON의 body를 받는다 -> class-transformer로 클래스 인스턴스로 변환 -> class-validator로 userId가 email형식으로 써졌나 ? 뭐 이런 느낌 ( 아래의 예시 참고) 친절한 NestJS는 뭐가 이상한 지 다 알고있고 계획이 있다 캬 죠타.. 일단 Install 유남셍? 사전 설치: npm i --save class-validator class-transformer Typescript는 가능 / Vanilla..
redis의 이벤트 채널 및 Pub/Sub pattern의 이해 1. redis 채널의 이해 설명: publisher는 subscriber에게 메세지를 보낸다 -> Redis = Event Serivce(이벤트 채널)에서 메시지를 categorized 즉 분류해서 이벤트 채널에 저장한다 -> subscriber는 publisher의 존재 자체를 모르고 원하는 메세지만 받는다. 요약: publisher가 redis 특정 channer name에 메세지를 보내면 같은 채널을 구동하는 subscribe 어플리케션은 메세지를 받는다. 2. socket.io가 redis의 pub/sub channel를 사용하는 방법 그림1. client A, E에게 보낸다고 가정: server1(pub)은 message를 Redis의 특정 채널에 보낸다. server1 (sub1) 과 ser..
변수를 참조하는 데 스플랫(splat) 연산자 '@'를 사용할 수 없습니다 1. 문제 발생 redis 소켓 어댑터 패키지를 설치하려고 npm에서 아래와 같이 복사 후 설치했는 데 에러가 똬! npm i --save redis socket.io @socket.io/redis-adapter 2. 문제해결: "@socket.io/redis-adapter" 처리 npm i --save redis socket.io "@socket.io/redis-adapter"
NestJS와 socket.io 사용법 1. 서버에서 socket.io 설치 npm i socket.io 2. socket 설정 [event.gateway.ts] import { Logger } from '@nestjs/common'; import { ConnectedSocket, MessageBody, OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit, SubscribeMessage, WebSocketGateway, WebSocketServer, } from '@nestjs/websockets'; import { Socket } from 'socket.io'; import { Server} from 'ws'; ✅ @WebSocketGateway(8080, { path: '/chat', ✅ c..
웹소켓과 소켓의 차이와 공통점 socket이란 ? OSI 7계층 중 4계층인 전송계층 소켓은 TCP/IP 4계층에서 전송 계층 위에 놓임 client는 IP:127.0.0.1와 port:3000를 통해 서버를 찾는다 -> socket -> 서버: IP: 127.0.0.1:3000를 찾음 인터넷에서 '소켓'을 찾아서 연결하고 데이터를 송수신한다. TCP 소켓은 'stream'을 UDP소켓을 위해서는 '데이터 그램'타입의 지정이 가능하다. 호스트가 여러개의 소켓을 가지고 다른 호스트들과 데이터를 주고 받을 수 있다. 예시로 채팅을 생각해보면 여러개의 소켓을 하나의 포트로 사용하여 구현이 가능하다. 우선 WEBSOCKET과 socket의 차이점은 ? 웹 소켓은HTTP 레이어에서 작동하는 소켓으로 TCP/IP 소켓의레이어가 다르다! 소켓은 ..

728x90