inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

176만명의 커뮤니티!! 함께 토론해봐요.

playground 오류 10-06-one-to-one

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

다음과 같이 playground에서 mutation한 결과 "Cannot return null for non-nullable field Product.productSalesLocation." 오류 메시지가 뜹니다. mutation안의 반환값으로 product의 column만 받을 때는 오류 없이 작동되었는데 productSalesLocation의 column을 반환하려 하면 다음과 같이 오류가 뜹니다. 위 사진을 보시면 DBeaver에 product와 saleslocation에 생성한 값이 잘 입력되었지만 product table에서 productSalesLocationID가 NULL값으로 되어있습니다. 이 부분에 연관된 코드가 여러 파일로 나뉘어져있어 코드 어느 부분을 확인해야 하는지 알려주시면 해당 코드 캡처본을 보내드리겠습니다.

  • javascript
  • node.js
  • docker
  • rest-api
  • nestjs
  • playground
장주윤 댓글 2 좋아요 0 조회수 343

token 재발급문제

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

강의 잘듣고 있습니다. 유투브에서 flutter 영상만 보다가 평소 관심있었던 nest 까지 이어왔습니다(자바스크립트, 타입스크립트 그리고 nestjs까지) 토큰 관련 마지막강의해서 refresh token 이 만료되면 다시 ....refresh end point 로 요청을 보내서 다시 refresh 토큰을 받는다 말씀하셨는데요... 기간 만료된 refresh 토큰을 보내도 되는건가요? 아님 그 기능을 따로 구현해야 하는건가요?

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
정윤근 댓글 2 좋아요 0 조회수 409

여전히 타겟을 찾을 수 없습니다..

미해결

Java 마이크로서비스(MSA) 프로젝트 실습

강의와 같은 버전으로 모두 같게 진행하지 않아서 그런지.. windows 타겟을 찾을 수가 없습니다. 전에 AI가 알려준 건 도움이 되질 않았어요 분명 prometheus 타겟은 잡힌 것으로 봐서는 app 폴더 내부로 들어가서 prometheus.yml 파일도 잘 읽은 것 같은데요.. 왜 그대ㅑ로 아래에 job_name이 windows인 것은 왜 설정이 안 되는지 모르겠습니다..

  • java
  • spring
  • rest-api
  • spring-boot
  • msa
김병철 댓글 1 좋아요 0 조회수 361

followeeCount, followerCount 증가, 감소를 위한 메소드 일반화하기 코드 공유

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

increment(conditions: FindOptionsWhere<Entity>, propertyPath: string, value: number | string) 먼저 increment메소드의 propertyPath 부분이 특정 Model의 프로퍼티를 추론 하지 않고 string으로 박혀 있는게 마음에 들지 않아서 대상이 되는 프로퍼티 필드 명을 추론 하게 작성 했습니다. // users.service.ts async incrementFollowerCount( userId: number, fieldName: keyof Pick<UsersModel, 'followerCount' | 'followeeCount'>, incrementCount: number, qr?: QueryRunner, ) { const usersRepository = this.getUsersRepository(qr); await usersRepository.increment( { id: userId, }, fieldName, incrementCount, ); } 1. fieldName: 어떤 프로퍼티를 증가, 감소를 할것인지 특정하는 파라미터 2. incrementCount : 몇 증가 시킬것인지 증가 value // users.service.ts async decrementFollowerCount( userId: number, fieldName: keyof Pick<UsersModel, 'followerCount' | 'followeeCount'>, decrementCount: number, qr?: QueryRunner, ) { const usersRepository = this.getUsersRepository(qr); await usersRepository.decrement( { id: userId, }, fieldName, decrementCount, ); } contoller에서 사용하기 // users.controller.ts @Patch('follow/:id/confirm') @UseInterceptors(TransactionInterceptoer) async patchFollowConfirm( @User() user: UsersModel, @Param('id', ParseIntPipe) followerId: number, @QueryRunnerDecorator() qr: QueryRunner, ) { await this.usersService.confirmFollow(followerId, user.id); await this.usersService.incrementFollowerCount( user.id, 'followerCount', 1, qr, ); await this.usersService.incrementFollowerCount( followerId, 'followeeCount', 1, qr, ); return true; } @Delete('follow/:id') @UseInterceptors(TransactionInterceptoer) async deleteFollow( @User() user: UsersModel, @Param('id', ParseIntPipe) followeeId: number, @QueryRunnerDecorator() qr: QueryRunner, ) { await this.usersService.deleteFollow(user.id, followeeId); await this.usersService.decrementFollowerCount( user.id, 'followerCount', 1, qr, ); await this.usersService.decrementFollowerCount( followeeId, 'followeeCount', 1, qr, ); return true; } filedName 파라미터를 특정 프로퍼티만 올 수 있게 자동완성 잘됩니다. 팔로워 confirm 되면 나의 follower 증가 + 상대방 followee 증가 팔로워 삭제 되면 나의 follower 감소 + 상대방 followee 감소 await this.usersService.incrementFollowerCount( followerId, 'followeeCount', 1, qr, ); userId가 오는 파라미터 자리에 user.id 가 아닌 followerId가 들어간 이유는 followeeCount를 증가 해야 되기 때문이다. 즉, 팔로워를 수락 했으면 나의 followerCount를 증가 시키고 상대방 followeeCount를 증가 시켜야 되기 때문에, 삭제 했을때도 같은 원리 [결과] 2번 사용자가 1번 사용자를 팔로워하고, 1번 사용자가 팔로워를 수락 했을때

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
rhkdtjd_12 댓글 1 좋아요 0 조회수 293

@IsPublic 어노테이션으로 RefreshTokenGuard에서 RefreshToken 검증을 하기 위한 코드 공유

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

// is-public.const.ts export enum IsPublicEnum { ISPUBLIC = 'ISPUBLIC', ISREFRESHTOKEN = 'ISREFRESHTOKEN', } // is-public.decorator.ts import { SetMetadata } from '@nestjs/common'; import { IsPublicEnum } from '../const/is-public.const'; export const ISPUBLIC_KEY = 'is_public'; export const IsPublic = (status: IsPublicEnum) => SetMetadata(ISPUBLIC_KEY, status); // bearer-token.guard.ts @Injectable() export class BearerTokenGuard implements CanActivate { constructor( private readonly authService: AuthService, private readonly usersService: UsersService, public readonly reflector: Reflector, ) {} async canActivate(context: ExecutionContext): Promise<boolean> { const req = context.switchToHttp().getRequest(); const requiredPublic = this.reflector.getAllAndOverride(ISPUBLIC_KEY, [ context.getHandler(), context.getClass, ]); if (requiredPublic) { req.requiredPublic = requiredPublic; } if (requiredPublic === IsPublicEnum.ISPUBLIC) { return true; } const rawToken = req.headers['authorization']; if (!rawToken) throw new UnauthorizedException('토큰이 없습니다!'); const token = this.authService.extractTokenFromHeader(rawToken, true); const result = await this.authService.verifyToken(token); const user = await this.usersService.getUserByEmail(result.email); req.user = user; req.token = token; req.tokenType = result.type; return true; } } 추가된 코드 if (requiredPublic) { req.requiredPublic = requiredPublic; } requiredPublic 있을때만 req에 담아줌. 추가된 코드 if (requiredPublic === IsPublicEnum.ISPUBLIC) { return true; } IsPublic일때만 return true 즉, ISREFRESHTOKEN 일때는 아래 로직들이 정상적으로 실행됨. // bearer-token.guard.ts @Injectable() export class AccessTokenGuard extends BearerTokenGuard { async canActivate(context: ExecutionContext): Promise<boolean> { await super.canActivate(context); const req = context.switchToHttp().getRequest(); if ( req.requiredPublic === IsPublicEnum.ISPUBLIC || IsPublicEnum.ISREFRESHTOKEN ) { return true; } if (req.tokenType !== 'access') { throw new UnauthorizedException('Access Token이 아닙니다.'); } return true; } } 추가된 코드 if (req.requiredPublic === IsPublicEnum.ISPUBLIC || IsPublicEnum.ISREFRESHTOKEN) { return true; } req.requiredPublic이 ISPUBLIC이거나 ISREFRESHTOKEN이면 return true로 global accessTokenGuard return true로 빠져나옴. // bearer-token-guard.ts @Injectable() export class RefreshTokenGuard extends BearerTokenGuard { async canActivate(context: ExecutionContext): Promise<boolean> { await super.canActivate(context); const req = context.switchToHttp().getRequest(); if (req.tokenType !== 'refresh') { throw new UnauthorizedException('Refresh Token이 아닙니다.'); } return true; } } 변경 사항 없음. 왜냐하면 위에서 정상적으로 refreshToken을 verify하고 req에 값이 담겼기 때문에 RefreshTokenGuard가 정상적으로 실행 되어야함. auth.controller에 적용하기 @Controller('auth') export class AuthController { constructor(private readonly authService: AuthService) {} @IsPublic(IsPublicEnum.ISREFRESHTOKEN) @Post('token/access') @UseGuards(RefreshTokenGuard) postTokenAccess(@Headers('authorization') rawToken: string) { ... } @IsPublic(IsPublicEnum.ISREFRESHTOKEN) @Post('token/refresh') @UseGuards(RefreshTokenGuard) postTokenRefresh(@Headers('authorization') rawToken: string) { ... } @IsPublic(IsPublicEnum.ISPUBLIC) @Post('login/email') @UseGuards(BasicTokenGuard) postLoginEmail(@Headers('authorization') rawToken: string) { ... } @IsPublic(IsPublicEnum.ISPUBLIC) @Post('register/email') postRegisterEmail(@Body() body: RegisterUserDto) { ... } }

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
rhkdtjd_12 댓글 2 좋아요 0 조회수 370

별거 아니긴 한데 nest-cli 로 만들때

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

nest cli로 resource 만들때 경로를 / 넣어주면 아래에 바로 생성 됩니다. nest g resource posts/comments 이렇게 하면 posts폴더 아래에 comments가 생깁니다!

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
rhkdtjd_12 댓글 1 좋아요 1 조회수 428

가드와 미들웨어 질문드립니다.

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

안녕하세요., 강의 잘 보고있습니다. 가드랑 미들웨어 용도를 이렇게 이해하면 좋을까요? 1.가드: -특정 컨트롤러로 들어온 파라매터, 혹은 context데이터를 가공하거나 검증하고 싶을때 2.미들웨어: -특정 규칙을 가진 패쓰 혹은 컨트롤러 전체에 데이터를 검증하고 싶을때 아주 맨 처음에 저는 token 을 검증하는 BearerTokenGuard이 가드보다는 middleware 로 가는것이 맞지 않나 싶었는데요. context.user 데이터를 controller 에 내려주기 위해 IsCommentMine Guard 처럼 다른 가드로 유저데이터를 넘겨줘야하는 경우가 있어서 가드로 사용하는것으로 이해했는데 맞을까요? (그리고 middleware 로는 불가능한걸까요?)

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
닥부 댓글 1 좋아요 1 조회수 291

update comment 관련

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

안녕하세요. update comment 관련 두가지 질문이 있습니다. update(patch) 에서는 query runner를사용하지 않아도 되나요? update 시에repository.update 가 아닌 save 를 사용한 이유가 있을까요? 항상 강의 잘 보고있습니다. 감사합니다!

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
닥부 댓글 2 좋아요 0 조회수 348

섹션5의 2번째 강의 질문-setMap 비동기 처리 이유

미해결

비전공자를 위한 풀스택 맛집지도 만들기 프로젝트!: Front, Back-end 그리고 배포까지

제가 이해한 바가 맞는지 질문드립니다. 질문1. 마커를 찍을 시: 1. 주소를 좌표로 변환 2. 해당 좌표를 마커로 지도에 표시 의 처리 순서가 보장되어야 하므로, async await를 이용한 비동기처리를 해준 것이 맞나요? 질문 2. 비동기처리를 해주기 전에도 마커는 잘 찍혔는데, 그 말은 즉 주소를 좌표로 변환하고-> 좌표를 마커로 표시하는 순서로 코드가 실행되었다는 것 아닌가요? 그렇다면 api가 비동기적으로 이루어진다는 말이 잘 와닿지 않아서 질문드립니다. 감사합니다!

  • HTML/CSS
  • javascript
  • aws
  • git
  • mysql
  • rest-api
  • github
이다윤 댓글 1 좋아요 0 조회수 277

Intellij Database에서 테이블 조회

미해결

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

브라우저로 접속하였을 때는 테이블이 정상적으로 생성되는데 인텔리제이 자체에서 확인하면 왜 테이블이 보이지 않는걸까요? 새로고침해봐도 나타나지 않습니다

  • rest-api
  • spring-boot
강프로그래머 댓글 2 좋아요 0 조회수 747

제 json은 왜 이렇게 나올까요?

미해결

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

(사진)

  • rest-api
  • spring-boot
강프로그래머 댓글 1 좋아요 0 조회수 349

제 json은 왜 이렇게 나올까요?

미해결

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

(사진)

  • rest-api
  • spring-boot
강프로그래머 댓글 1 좋아요 0 조회수 373

섹션5의 Post 요청 만들기에서 질문있습니다.

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

안녕하세요. 섹션5의 Post 요청 만들기 영상을 보다가 궁금증이 생겨 질문드립니다. Q1) 새로운 post 생성시 id를 부여할 때 배열의 마지막 인덱스 아이템을 꺼내 해당 아이템의 id에 1을 더하셨습니다. 그런데 배열 안의 아이템 순서가 꼭 id-오름차순으로 정렬되어있을거란 보장이 없기 때문에 배열에서 가장 큰 id를 찾은 후, +1을 하여 새로운 id를 부여해줘야하지 않을까 싶은데 제가 잘못 생각하고 있는걸까요? Q2) 새로운 post를 기존 배열에 push하지 않고, spread 방식으로 추가해주셨는데 특별한 이유가 있는건지도 궁금합니다!

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
JB_ 댓글 1 좋아요 0 조회수 273

Transform이 적용이 안됩니다.

미해결

[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core

Transform을 적용해도 path값에 public/posts값이 붙지 않은 채로 계속 나옵니다. main.ts파일에 위와 같이 적용을 해도 안되는데 혹시 원인을 알 수 있나요?

  • javascript
  • typescript
  • rest-api
  • nestjs
  • backend
코린이 댓글 1 좋아요 0 조회수 339

소스코드는 어디에 있을까요??

해결됨

[리뉴얼] 처음하는 파이썬 백엔드와 웹기술 입문 (파이썬 중급, flask[플라스크] 로 이해하는 백엔드 및 웹기술 기본) [풀스택 Part1-1]

강의 듣는 중에 소스나 참고자료는 어디서 다운로드 받을 수 있을까요? ㅎㅎ

  • python
  • rest-api
  • flask
이서호 댓글 1 좋아요 1 조회수 297

디폴트와 en이 작동하지 않습니다

미해결

[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발

다른 ko, ja, ch 는 모두 동작하지만 Accept-Language를 설정하지 않거나 Accept-Language를 en으로 설정하여도 계속 안녕하세요 한글이 나오고 있습니다. 무슨 문제일까요..? https://github.com/KMSKang/my-restful-service

  • rest-api
  • spring-boot
강프로그래머 댓글 1 좋아요 0 조회수 232

배포하기 챕터에서 도커컴포즈 빌드->업 후 로그 확인하면 sh: 1: nest: not found 오류

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

안녕하세요! 강사님 강의 잘 듣고 있습니다. 섹션 19. 17-01 강의를 따라하고 있는데 쉘에 깃클론 -> 환경변수 파일 만들고 -> 도커 컴포즈 빌드 -> 도커 컴포즈 업 이렇게 명령어를 따라갔는데 로그가 너무 오래 찍히더라구요! 무슨일인가 싶어 일단 취소하고 docker ps -a 명령어로 확인해봤더니 서버가 만들어지고 꺼진 것 같더라구요 해당 image 아이디를 가지고 docker logs 를 봤는데 위와 같은 메세지가 나옵니다. 검색해봤더니 nest/cli를 devDependencies 에서 빼고 dependencies 에 넣으라고 해서 그렇게 했는데도 오류는 동일하게 나오네요 ㅠㅠ 혹시 몰라 도커파일에 RUN npm install @nestjs/cli 를 추가해봤는데 이번에는 swagger pluginrs 가 설치되지 않았다는 오류가 나옵니다. 어떻게 하면 좋을까요??

  • javascript
  • node.js
  • docker
  • rest-api
  • nestjs
김정원 댓글 1 좋아요 0 조회수 307

wmi exporter - prometheus 연동 실패

미해결

Java 마이크로서비스(MSA) 프로젝트 실습

prometheus 와 WMI exporter 연동이 왜 안되는지 모르겠습니다. global: scrap_interval: 15s evaluation_interval: 15s scrape_configs: - job_name: "prometheus" static_configs: - targets: ["localhost:9090"] - job_name: "windows" static_configs: - targets: ["192.168.0.101:9182"] 위와같이 제 pc의 ip를 192.168.0.101로 설정했습니다. cmd창에서 확인한 것입니다. PS D:\study-workspace\springBoot-workspace\iron-msa> ipconfig Windows IP 구성 이더넷 어댑터 vEthernet (Default Switch): 연결별 DNS 접미사. . . . : 링크-로컬 IPv6 주소 . . . . : fe80::2609:80c8:ea62:2e07%31 IPv4 주소 . . . . . . . . . : 192.168.16.1 서브넷 마스크 . . . . . . . : 255.255.240.0 기본 게이트웨이 . . . . . . : 이더넷 어댑터 이더넷: 연결별 DNS 접미사. . . . : 링크-로컬 IPv6 주소 . . . . : fe80::f3d1:5994:1b9d:5bf8%9 IPv4 주소 . . . . . . . . . : 192.168.0.101 서브넷 마스크 . . . . . . . : 255.255.255.0 기본 게이트웨이 . . . . . . : 192.168.0.1 연결별 DNS 접미사. . . . : 이더넷 어댑터 vEthernet (WSL): 연결별 DNS 접미사. . . . : 링크-로컬 IPv6 주소 . . . . : fe80::a35b:8530:2f6d:4eb9%38 IPv4 주소 . . . . . . . . . : 172.18.0.1 서브넷 마스크 . . . . . . . : 255.255.240.0 기본 게이트웨이 . . . . . . : 아래는 혹시 ip를 잘못지정한 것일까봐 확인한 것입니다. 도와주실 수 있나요

  • java
  • spring
  • rest-api
  • spring-boot
  • msa
김병철 댓글 2 좋아요 0 조회수 558

데코레이터가 잘 이해가 안갑니다.

해결됨

[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스

@Field 하면 어떠한 객체에 있는것에 있는 Field 를 가져다 쓸거야~ 라고 말하면서 그러한 함수를 불러오는 건가요?? ㄷ

  • javascript
  • node.js
  • docker
  • rest-api
  • nestjs
훅룩국묵 댓글 1 좋아요 0 조회수 287

인기 태그

인프런 TOP Writers

주간 인기글