묻고 답해요
130만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - Part 1 NestJS Core
findOne 사용 이유
강의 8:23에 createChat 함수의 리턴값으로 save 함수에서 반환된 chat을 사용하지 않고 findOne 함수를 통해 조회한 chat을 사용하신 이유가 궁금합니다!
-
해결됨Slack 클론 코딩[백엔드 with NestJS + TypeORM]
socket io 미 연결 문제 (nest & flutter)
안녕하세요! socket관련한 서비스를 진행해보고 싶어서 제로초님의 강의를 들은 수강생입니다.현재 nest & flutter를 이용하고 있는데, flutter에서의 연결 및 다른 tool에서 socket io 연결이 되지 않으며 “외부 사이트로는 접근이 불가능한 오류”가 생겨서 조심스럽게 여쭤봅니다. 현재 로직은 채팅을 생성시, 채팅을 보여주는 리스트가 실시간으로 새로고침이 되는 부분을 작업중입니다.하지만, postman, httpie, hoppscotch의 부분에서 연결이 되지 않는 문제가 발생합니다.많은 방법을 찾아봤지만, 터미널에서 socket io cli를 통해서 로그는 볼 수 있지만, 다른 tool에서는 이용이 불가능한 방법에 대해서 알고 싶어서 질문드립니다!Socket io를 통해서 local, dev서버 연결 완료 하지만 postman의 socket io기능을 통해서 테스트를 진행하려고 할 때,postman으로 연결local에서는 문제가 없이 연길이 되지만, dev서버에서는 이러한 에러가 발생합니다. 또한 flutter 앱에서 연결을 하려면 다음과 같은 에러가 발생합니다.오류 메시지 "WebSocketException: Connection to 'http://~~~~.com:81/socket.io/?EIO=4&transport=websocket#' was not upgraded to websocket"는 클라이언트가 WebSocket 연결을 시도하였으나, 서버가 해당 연결을 WebSocket 프로토콜로 업그레이드하지 않았다는 것을 의미합니다. 이는 여러 가지 원인에 의해 발생할 수 있습니다: upgrade가 되지 않았다고 나와서 ,ngnix의 socket 부분에서 upgrade부분도 잘 넣어줬는데, 오류가 해결되지 않아서... 고민 끝에 질문 올립니다.Ngnix 설정부터 2주정도 시간을 들였지만, 해결이 되지 않아서…여쭤봅니다.방화벽도 해제가 되어 있는데 연결이 안되고 있습니다..다음은 nest에서 작성한 코드 입니다![chat.gateway.ts]import { WebSocketGateway, WebSocketServer, SubscribeMessage, OnGatewayConnection, OnGatewayDisconnect, OnGatewayInit, ConnectedSocket, MessageBody, } from '@nestjs/websockets'; import { Server, Socket } from 'socket.io'; @WebSocketGateway() export class ChatGateway implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect { @WebSocketServer() server: Server; afterInit(server: Server) { console.log('WebSocket initialized'); } handleConnection(client: Socket) { console.log(`Client connected: ${client.id}`); // 수정: client 객체 직접 출력 대신 id 출력 } handleDisconnect(client: Socket) { console.log(`Client disconnected: ${client.id}`); } @SubscribeMessage('sendMessage') handleMessage( @ConnectedSocket() client: Socket, @MessageBody() data: { message: string } ): void { console.log(`Received message from ${client.id}: ${data.message}`); this.server.emit('newMessage', data); // 모든 클라이언트에게 메시지 전송 console.log(`Received message: ${data.message}`); } } [main.ts]import { ConfigService } from '@nestjs/config'; import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { join } from 'path'; import { AppModule } from './app.module'; import { HttpExceptionFilter } from './common/exceptions/http-exception.filter'; import { SuccessInterceptor } from './common/interceptors/success.interceptor'; import { IoAdapter } from '@nestjs/platform-socket.io'; import { CustomIoAdapter } from './adapters/custom-io.adapter'; async function bootstrap() { const app = await NestFactory.create<NestExpressApplication>(AppModule); app.useWebSocketAdapter(new CustomIoAdapter(app)); const configService = app.get(ConfigService); const port = configService.get('server.port'); const mongoUrl = configService.get('DB.MONGO_URL'); console.log('MongoDB URL:', mongoUrl); app.enableCors({ origin: true, credentials: true, }); app.useStaticAssets(join(__dirname, '..', 'client'), { prefix: '/api/v1/client', }); app.useGlobalInterceptors(new SuccessInterceptor()); app.useGlobalFilters(new HttpExceptionFilter()); app.setGlobalPrefix('api/v1'); const swagger_options = new DocumentBuilder() .setTitle('Nyam-Docs') .setDescription('API description') .setVersion('2.0.1') .addApiKey( { type: 'apiKey', name: 'x-token', in: 'header', description: 'Enter token', }, 'x-token', ) .addApiKey( { type: 'apiKey', name: 'x-type', in: 'header', description: 'Enter type', }, 'x-type', ) .build(); const document = SwaggerModule.createDocument(app, swagger_options); SwaggerModule.setup('api-docs', app, document); await app.listen(port, '0.0.0.0'); console.log(`Application Listening on Port : ${port}`); } bootstrap();다음은 custom한 io입니다[custom.io.adpter.ts]import { IoAdapter } from '@nestjs/platform-socket.io'; import { INestApplication, Injectable } from '@nestjs/common'; import { ServerOptions } from 'socket.io'; @Injectable() export class CustomIoAdapter extends IoAdapter { constructor(app: INestApplication) { super(app); } createIOServer(port: number, options?: ServerOptions): any { const serverOptions: ServerOptions = { ...options, cors: { origin: '*', // 모든 도메인에서 접근 허용 methods: ['GET', 'POST', 'PUT', 'DELETE'], credentials: true }, transports: ['websocket', 'polling'], //pooling 없으면 연결 안 됨(socket) allowEIO3: true // Engine.IO 3.x 버전 클라이언트 허용 }; return super.createIOServer(port, serverOptions); } } 혹시 해결방법을 아시거나, 도움을 주실만한 정보가 있으시다면 알려주시면 정말 감사하겠습니다!
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - Part 1 NestJS Core
섹션26 FileIntercepter적용문의
- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요! - 먼저 유사한 질문이 있었는지 검색해보세요. - 서로 예의를 지키며 존중하는 문화를 만들어가요. - 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.코드팩토리 통합 링크https://links.codefactory.aiFlutter 강의를 구매하시면 코드팩토리 디스코드 서버 플러터 프리미엄 채널에 들어오실 수 있습니다! 디스코드 서버에 들어오시고 저에게 메세지로 강의를 구매하신 이메일을 보내주시면 프리미엄 채널에 등록해드려요! 프리미엄 채널에 들어오시면 모든 질의응답 최우선으로 답변해드립니다!
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - Part 1 NestJS Core
섹션26 FileIntercepter적용 질의
분명 postman으로 FormData로 설정하신후title,content,image를 보내셨는데 어떻게Nestjs에서 @Body()로 받을수 있나요 Http요청이니 req.body 형식으로 접근 가능한게 아닐까요??
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - Part 1 NestJS Core
configService와 process.env
안녕하세요 코팩님!class 작성 시에 다른 class를 상속하여 작성하는 경우 있잖아요nestjs/passport를 이용해서 구글 oauth 로그인을 구현하려고 합니다.import { PassportStrategy } from '@nestjs/passport'; import { Strategy } from 'passport-google-oauth20'; import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; @Injectable() export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { constructor(private readonly configService: ConfigService) { super({ clientID: this.configService.get('GOOGLE_CLIENT_ID'), clientSecret: this.configService.get('GOOGLE_CLIENT_SECRET'), callbackURL: 'http://localhost:3000/auth/google/callback', scope: ['email', 'profile'], }); }이 경우에super() 호출 전에 this를 참조하려고 해서 에러가 발생합니다.이런 경우에는 불가피하게 그냥 @Injectable() export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { constructor() { super({ clientID: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, callbackURL: 'http://localhost:3000/auth/google/callback', scope: ['email', 'profile'], }); }이렇게 직접 환경변수를 적어주는 방법 밖에는 없을까요?
-
해결됨맛집 지도앱 만들기 (React Native + NestJS)
현재위치 문제
현재위치 강의를 보고 이렇게 강의 처럼 서울에 뜨긴하는데 왜 서울로 뜨는건가요?? 저는 서울의 거주중이 아닌데..
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - Part 1 NestJS Core
섹션 6에서 코드를 서비스 단으로 옮기고 난뒤부터 get 메소드가 제대로 작동하지 않아요
강의를 따라서 로직을 서비스 단으로 옮긴 뒤부터 response 코드 200인데 내용이 posts들이 오지 않아요getPostsbyId도 이렇게 되고 getAllPosts도 이렇게 됩니다 도와주세요 ㅠㅠ나머지 put이랑 post , delete 는 제대로 작동합니다 ㅠㅠ
-
해결됨맛집 지도앱 만들기 (React Native + NestJS)
drawer를 적용하고 나서 오류가 뜹니다...
ERROR Error: [Reanimated] Failed to create a worklet. See https://docs.swmansion.com/react-native-reanimated/docs/guides/troubleshooting#failed-to-create-a-worklet for more details., js engine: hermes at DrawerViewBase (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.matzip&modulesOnly=false&runModule=true:167363:22) at RNGestureHandlerRootView at GestureHandlerRootView (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.matzip&modulesOnly=false&runModule=true:164680:21) at RNCSafeAreaProvider at SafeAreaProvider (http://10.0.2.2:8081/index.bundle//&platform=android&dev=true&lazy=true&minify=false&app=com.matzip&modulesOnly=false&runModule=true:134394:24).....이러한 오류가 계속 뜨네요 해결방법을 혹시 알고계신지요ㅠ
-
해결됨맛집 지도앱 만들기 (React Native + NestJS)
회원가입 버튼을 눌러도 로그는 들어오는데 반응이 없어서요
어디서 에러를 살펴볼수있을까요? DB에도 들어가질 않습니다.
-
미해결Slack 클론 코딩[백엔드 with NestJS + TypeORM]
no elements in sequence 에러 관해서 질문이 있습니다.
안녕하세요. nestjs를 사용해서 백엔드를 구성하고 있는데 RxJS의 no elements in sequence라는 에러에 대해서 질문이 있습니다.const findObject = await this.respository.findOne({ where: { data } }) if (findObject) { throw new HttpException("중복 접수 되었습니다.", HttpStatus.CONFLICT); }DB에서 찾은 객체가 있을 경우, Exception으로 에러를 내면서 종료를 시키는 로직을 생각하고 작성을 했습니다. 그런데 정작 오류는 no elements in sequence 와 함께 500 응답코드가 반환되는데요.반환 할 값이 없을경우 나는 에러로 알고있는데, throw만 하고 리턴하는 값이 없어서 발생 하는 것 같습니다.그리고 발생하는 두 오류 중, no elements in sequence가 먼저 반환되어 종료되기때문에 409에러가 묻히는 것으로 추측을 하고있는데 409에러를 먼저 내는 방법은 없을까요?
-
해결됨맛집 지도앱 만들기 (React Native + NestJS)
[8-2] 카카오 로그인 구현하기 with WebVIew
안녕하세요.강의를 들으면서 카카오 로그인부터 부분부터 구현하고 있는 수강생입니다. 카카오 로그인을 진행하는데 ID와 PW를 입력하고 들어가면 Admin Settings Issue (KOE101)이라는 에러 창이 나타납니다. 해당 에러는 확인해 보면 'App Key'를 잘못 등록했을 때 발생하는 것이라고 확인하고 다시 확인해 봤지만 계속 같은 에러만 발생하는 상황입니다. 해결 방법 질문 드립니다.ㅠㅠ
-
미해결타입스크립트의 모든 것
BuilderInit 사용 이유
안녕하세요~ 좋은 강의 감사합니다~spring 3년 정도 사용하다가 이번에 이직 하면서 nest.js를 사용하게 되어 강의 듣고 있는데요. js지식이 얕아서 간혹 이해 안되는 부분이 생기더라구요.찾아보면서 진행하고 있긴한데 이번강의의 BuilderInit클래스를 추가해주신 부분이 이해가 잘되지 않아서 문의드려요~ 데코레이터는 "값 조작 은 인스턴스화 해서 실행해야 한다"라고 지난 강의에서 말씀해주셨는데new PostEntity.Builder()를 하였을 때 컴파일 타임에 Builder() 와 멤버변수()를 인식하지못해서 사용하는 건가요? class BuilderInit {static Builder = class {build() {};[props: string]: Function;}}이 문법도 잘이해가 가질 않지만, 메소드의 시그니처를 정의해주는걸로 보이는데요(?), build()가 있어야 하는 이유가 뭘까요? build()도 정의해주는 것으로 봤는데 없애도 문제없이 동작하더라구요.
-
해결됨맛집 지도앱 만들기 (React Native + NestJS)
[3-8] React Query 도입(2) - 로그인 연동하기
[3-8] React Query 도입(2) - 로그인 연동하기 아침에도 질문올리고 또 올리네요 ㅠ거의 하루종일 이 부분 학습하고 회원가입 로그인 했는데어떠한 오류도 없고 회원가입, 로그인이 안되서 질문 남깁니다.강의 파일 비교해봐도 특별히 오타가 없는거 같은데요혹시 깃주소 올리면 봐주시나요?
-
해결됨맛집 지도앱 만들기 (React Native + NestJS)
[3-7] 백엔드 서버 실행하기 에서 에러로 폴더 생성이 안되는경우
[3-7] 백엔드 서버 실행하기 에서 에러로 폴더 생성이 안되는경우 인데요unable to connect to server : connection timeout expired 이렇게 뜨고 폴더 생성이 안되는데요기존 설치되었던 pgAdmin이 이상이 있나싶어 다시 설치하려고 하는데요어떤걸 설치해야할지 모르겠습니다.저는 윈도우 86-64인데요 버전이 너무 많아서요수업 잘 듣고 있는데 여기서 막히네요 ㅠㅠ 터미널에서 서버를 실행하니src/image/image.controller.ts:14:25 - error TS2307: Cannot find module 'src/@common/constants' or its corresponding type declarations.14 import { numbers } from 'src/@common/constants';~~~~~~~~~~~~~~~~~~~~~~~Found 1 error(s).이런 오류가 뜨네요 어떻게 해야할까요? 깃파일에 오타가 있습니다
-
미해결맛집 지도앱 만들기 (React Native + NestJS)
ios 실행 이후 ➜ explicit dependency.. 뜨고 멈추는 경우 해결책 공유합니다.
xcode 15.3node 21.1.0프로젝트를 latest로 설치하면 문제가 없는데, 강의와 일치시키려고 0.72.6으로 설치하면 https://github.com/facebook/react-native/issues/39743위와 같은 에러가 발생했습니다.---xcode에서 직접 빌드 시키니, flipperKit에서 에러가 발생했습니다.---이럴 경우 해결 방법입니다.https://github.com/facebook/react-native/issues/43335저처럼 시간 쏟는 분들이 계실까봐 공유합니다.
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - Part 1 NestJS Core
vscode postgresql extension이 실행되지 않습니다.
강사님께서 설명해주신대로 입력해서 vscode extension 설치 후에 진행하려고 하는데 role "postgres" does not exist 라는 오류와 함께 extentsion 진행이 되지 않습니다. 혹시 무엇이 문제인지 알 수 있을까요?
-
해결됨맛집 지도앱 만들기 (React Native + NestJS)
사용하시는 vscode 테마가 무엇이죠?
사용하시는 vscode 테마가 무엇이죠?
-
미해결탄탄한 백엔드 NestJS, 기초부터 심화까지
error_code : Property 'user' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.ts(2339)
안녕하세요! 저와 같은 수강생 여러분, 반갑습니다.분명 저와 같은 에러를 겪고 분투하는 사람을 위해서 제 경험을 공유 드립니다. 저 같은 경우 선생님 코드를 그대로 따라 진행을 했었는데요.특히나 CustomDecoration 부분에 있어서 그대로 따라 진행을 했습니다. 정확히 이 부분에서 에러가 발생을 하더라구요.return request.user as CatCurrentDto; 에러의 내용은 아래와 같습니다.Property 'user' does not exist on type 'Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>'.ts(2339) 해결방안은 선생님이 보여주신 nestJS의 공식문서를 참고해서 다시 적어보았는데요. Request를 제거해주시면 저 부분이 잡힙니다. 버전이 자꾸 바뀌기때문에 매개변수, 메소드, 각각의 요구되는 필드값 또한 바뀌는것 같습니다. 무언가 잘 안될때는 제공해주신 공식문서 찾는것도 좋은 방법인거 같습니다. 저와 같은 에러를 만나신분에게 조금이나마 도움이 되었음좋겠습니다. 아래는 전체 로직 입니다. [user.decorator.ts] -> 제공된 소스코드 수정한 코드import { CatCurrentDto } from './../../cats/dto/cats.current.dto'; import { createParamDecorator, ExecutionContext } from '@nestjs/common'; export const CurrentUser = createParamDecorator( (data: unknown, ctx: ExecutionContext) => { const request = ctx.switchToHttp().getRequest(); return request.user as CatCurrentDto; }, ); [user.decorator.ts] -> 제공된 소스코드import { CatCurrentDto } from './../../cats/dto/cats.current.dto'; import { Request } from 'express'; import { Cat } from '../../cats/cats.schema'; import { createParamDecorator, ExecutionContext } from '@nestjs/common'; export const CurrentUser = createParamDecorator( (data: unknown, ctx: ExecutionContext) => { const request: Request = ctx.switchToHttp().getRequest(); return request.user as CatCurrentDto; }, );
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
파일명 짓고 구분하기가 어렵습니다
수업 거의 다 듣고 포트폴리오 만드는 중에 질문드립니다. fetchBoards로 게시판을 불러올때 리턴 객체명을 어떻게 해야할지 모르겠습니다. 예를 들어, board[], paging 값이 두개 리턴이 된다고 했을때 dto폴더에 select-board.output.ts 객체 파일을 만들어주면 될까요? 아니면 board[], paging 형태로 내보내는것은 나쁜 방식일까요? 웬만하면 프론트가 아니라 백에서 처리해서 내보내려고 합니다. 이런식으로 폴더 구분이랑 파일 이름 짓기가 모호한 경우가 많은데 여기에 초점을 맞춘다고 시간을 허비하지말고 구분만 잘해놓는게 좋을까요?
-
미해결[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - Part 1 NestJS Core
VScode postgresql 익스플로러 'Cannot get password' 에러
안녕하세요 강의 잘 보고 있습니다!다름이 아니고 VScode에서 postgres 익스플로러로 DB연결을 해주려는데 자꾸 오른쪽 밑에 'Cannot get password'라는 에러가 발생해서 연결이 되지 않습니다... yaml파일이랑 app.module도 잘 확인했는데 해당 에러때문에 DB 연결이 안됩니다. 확인 부탁드릴게요,, 캡쳐본입니다. post로 바꿔고 해봐서 현재 post입니다.