묻고 답해요
160만명의 커뮤니티!! 함께 토론해봐요.
인프런 TOP Writers
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
노션 자료에 링크가
노션 자료 중결제 - FrontEnd 적용페이지 안에 있는 링크가Page not found 로 나옵니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
몽고디비 접속 문제
노션에 써있는걸로 sudo systemctl start mongod 실행하면 실행이 안되서공식문서에서 찾아보니 sudo service mongod start를 입력하면 starting database mongod 라고 뜬 후 fail이 뜹니다.... localhost:27017로 접속을 하면 잘 뜨긴 하는데 해결 방법이 없을까요 ??
-
해결됨탄탄한 백엔드 NestJS, 기초부터 심화까지
tsc-watch
이거는 nodemon이랑 비슷한 개념인가요?..
-
해결됨탄탄한 백엔드 NestJS, 기초부터 심화까지
Mongoose API document
imports: [MongooseModule.forFeature([{ name: Cat.name, schema: CatSchema }])],에서 왜 name, schema 를 가지는 객체가 필요한지 궁금해서 타고 들어가봤더니, ModelDefinition타입이더라구요. 패키지에 도큐먼트 작성된 것이 없어서npm mongoose , nestjs/mongoose둘 다 찾아봤는데 mongoose 도큐먼트에는 따로 없었고,nestjs/mongoose 는 도큐먼트가 아예 안보이더라구요.. API 가 궁금할 때에는 어떤 방법으로 찾아 볼 수 있을까요..?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
도커내부 접속 안됨
docker run 이미지ID 하고 새로운 터미널 열어서 docker ps 로 containerID 확인 후docker exec -it 명령어 사용해서 도커 내부로 들어가려고 하면 OCI runtime exec failed: exec failed: unable to start container process: exec: "C:/Program Files/Git/usr/bin/bash": stat C:/Program Files/Git/usr/bin/bash: no such file or directory: unknown이런식으로 오류가 뜹니다 왜 그런건가요??해결 방법 알려주세요!
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
N:M tag 부분 구현 중 findOne 조회 부분 에러
products.service.ts에서 create 부근에 tag를 저장 하기 전 tag를 미리 조회하는 부분을 구현 중인데 findOne에서 {name: tagname} 을 구현하려고 할 때 다음과 같은 에러가 발생합니다. save에서는 에러가 발생하지 않는데 findOne 조회 부분만 에러가 발생하네요관련된 코드 같이 보내드립니다.createProduct.input.tsimport { InputType, Field, Int } from '@nestjs/graphql'; import { Min } from 'class-validator'; import { ProductSaleslocationInput } from 'src/apis/productsSaleslocation/entities/dto/productSaleslocation.input'; @InputType() export class CreateProductInput { @Field(() => String) name: string; @Field(() => String) description: string; @Min(0) @Field(() => Int) price: number; @Field(() => ProductSaleslocationInput) productSaleslocation: ProductSaleslocationInput; @Field(() => String) productCategotyId: string; @Field(() => [String]) productTags: string[]; } products.entity.tsimport { Field, Int, ObjectType } from '@nestjs/graphql'; import { ProductCategory } from 'src/apis/productsCategory/entities/productsCategory.entity'; import { ProductTag } from 'src/apis/productsTags/productTags.entity'; import { User } from 'src/apis/users/users.entity'; import { Column, DeleteDateColumn, Entity, JoinColumn, JoinTable, ManyToMany, ManyToOne, OneToOne, PrimaryGeneratedColumn, } from 'typeorm'; import { ProductSaleslocation } from '../../productsSaleslocation/entities/productsSaleslocation.entity'; @Entity() @ObjectType() export class Product { @PrimaryGeneratedColumn('uuid') @Field(() => String) id: string; @Field(() => String) @Column() name: string; @Field(() => String) @Column() description: string; @Field(() => Int) @Column() price: number; @Field(() => Boolean) @Column({ default: false }) isSoldout: boolean; @DeleteDateColumn() deletedAt: Date; @Field(() => ProductSaleslocation) @JoinColumn() @OneToOne(() => ProductSaleslocation) productSaleslocation: ProductSaleslocation; @Field(() => ProductCategory) @ManyToOne(() => ProductCategory) productCategory: ProductCategory; @Field(() => User) @ManyToOne(() => User) user: User; @JoinTable() @ManyToMany(() => ProductTag, (productTags) => productTags.products) @Field(() => [ProductTag]) productTags: ProductTag[]; } productTags.entity.tsimport { Field, ObjectType } from '@nestjs/graphql'; import { Column, Entity, ManyToMany, PrimaryGeneratedColumn } from 'typeorm'; import { Product } from '../products/entities/products.entity'; @Entity() @ObjectType() export class ProductTag { @Field(() => String) @PrimaryGeneratedColumn('uuid') id: string; @Column() @Field(() => String) name: string; @Field(() => [Product]) @ManyToMany(() => Product, (products) => products.productTags) products: Product[]; } products.service.tsimport { Product } from './entities/products.entity'; import { Injectable, UnprocessableEntityException } from '@nestjs/common'; import { Repository } from 'typeorm'; import { InjectRepository } from '@nestjs/typeorm'; import { ProductSaleslocation } from '../productsSaleslocation/entities/productsSaleslocation.entity'; import { ProductTag } from '../productsTags/productTags.entity'; @Injectable() export class ProductService { constructor( @InjectRepository(Product) private readonly productRepository: Repository<Product>, @InjectRepository(ProductSaleslocation) private readonly productSaleslocationRepository: Repository<ProductSaleslocation>, @InjectRepository(ProductTag) private readonly productTagRepository: Repository<ProductTag>, ) {} async findAll() { return await this.productRepository.find({ relations: ['productSaleslocation', 'productCategory', 'productTags'], }); } async findOne({ productId }) { return await this.productRepository.findOne({ where: { id: productId }, relations: ['productSaleslocation', 'productCategory', 'productTags'], }); } async create({ createProductInput }) { // 1. 상품만 등록하는 경우 // const result = await this.productRepository.save({ // ...createProductInput, // // 하나 하나 직접 나열하는 방식 // // name: createProductInput.name, // // description: createProductInput.description, // // price: createProductInput.price, // }); // 2. 상품과 상품거래 위치 같이 등록 const { productSaleslocation, productCategotyId, productTag, ...product } = createProductInput; const result = await this.productSaleslocationRepository.save({ ...productSaleslocation, }); // productTag // ["#electronics, #computer"] const result2 = []; // [{name: ..., id: ...}] for (let i = 0; i < productTags.length; i++) { const tagName = productTags[i].replace('#', ''); // check the tags that has already registered const checkTag = await this.productTagRepository.findOne({ name: tagName, }); // if the tags has been existed if (checkTag) { result2.push(checkTag); // if the tags hasn't been existed } else { const newTag = await this.productTagRepository.save({ name: tagName }); result2.push(newTag); } } const result3 = await this.productRepository.save({ ...product, productSaleslocation: result, // result 통째로 넣기 vs id만 넣기 productCategory: { id: productCategotyId }, productTags: result2, }); return result3; } async update({ productId, updateProductInput }) { const myProduct = await this.productRepository.findOne({ where: { id: productId }, }); const newProduct = { ...myProduct, id: productId, ...updateProductInput, }; return await this.productRepository.save(newProduct); } async checkSoldOut({ productId }) { const product = await this.productRepository.findOne({ where: { id: productId }, }); if (product.isSoldout) { throw new UnprocessableEntityException('Sold out'); } // if(product.isSoldout) { // throw new HttpException('이미 판매 완료 된 상품입니다.', HttpStatus.UNPROCESSABLE_ENTITY) // } } async delete({ productId }) { // 1. 실제 삭제 // const result = await this.productRepository.delete({ id: productId }); // return result.affected ? true : false // 2. 소프트 삭제(직접 구현) - isDeleted // this.productRepository.update({ id: productId }, { isDeleted: true }); // 3. 소프트 삭제(직접 구현) - deletedAt // this.productRepository.update({ id: productId }, { deletedAt: new Date() }); // 4. 소프트 삭제(TypeORM 제공) - softRemove - id로만 삭제 가능 // this.productRepository.softRemove({ id: productId }); // 4 . 소프트 삭제(TypeORM 제공) - softDelete const result = await this.productRepository.softDelete({ id: productId }); return result.affected ? true : false; } } 내용 확인 부탁드립니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
안녕하세요 질문있습니다!
@ObjectType이랑 @EntryType이랑 같이 사용을 할수는 없는건가요??dto와 entry가 다른부분이 없어서 같이 쓰는게 낫겠다싶어서 시도하려니 안되네요확실히 역할을 나눠야하는건가요??
-
해결됨탄탄한 백엔드 NestJS, 기초부터 심화까지
[2023.03.04 기준] 프론트앤드 빌드 방법 정리
해당 강의 프론트앤드 빌드 방법 정리합니다.강의 그대로 따라할 시에 제가 구성한 환경에서는 에러가 지속적으로 발생했습니다.에러 정보: Error: error:0308010C:digital envelope routines::unsupported환경 정보OS: MacOS Ventura 13.3 베타npm, npx version: 9.5.0node version: v18.14.2이에 따른 해결 방법 정리해봅니다. :)강의에 있는 git 프로젝트를 clone 한다.frontenddev 폴더 접근package.json 파일을 아래와 같이 작성 (dependencies 에서 antd 는 4.24.0 버전, 그 외는 2023.03.04 기준으로 최신 버전입니다. )frontenddev 폴더에서 sudo npx @next/codemod new-link . 을 실행한다.components/layouts/AccountForm.tsx 파일에서 <Link href="/signup"> 을 <Link href="/signup" legacyBehavior> 으로 변경Error: Invalid <Link> with <a> child. Please remove <a> or use <Link legacyBehavior>. 해결하기 위함입니다.참고 블로그: https://steady-learner.tistory.com/entry/Nextjs-Error-Invalid-Link-with-a-child-Please-remove-a-or-use-Link-legacyBehavior-%EC%98%A4%EB%A5%98npm i 후 npm run dev 하면 실행 됨을 확인할 수 있습니다.
-
해결됨Slack 클론 코딩[백엔드 with NestJS + TypeORM]
webstorm과 vscode
강의에서는 webstorm이 사용되던데,vscode로 강의를 따라가는데 어려움이 없을까요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
나만의미니프로젝트 cheerio관련질문
원하는 키워드의 값을 담은 상수를 console.log(key,value) 하면 줄바꿈되면서 안에 있는 전체 값들이 나오더라구요 ( const key = $(el).attr("property").split(":")[1]; const value = $(el).attr("content"); 부분입니다)근데 이 값들을 db에 저장하려 for문을 이용해 배열에 넣어봤더니 console.log(key,value)해서 나온 값들이 아닌 마지막 값만 들어갑니다 key와 value에 어떤 형태로 값이 스크랩핑되어 들어가있는건가요..?상수에 배열형태로 들어간 것도 아니고 한줄로 값이 들어간 것도 아니고 .. console.log하면 전체가 나오기는 하나줄바꿈이 되어 나와서 갈피를 못잡겠습니다..스크래핑한 값을 어떻게 저장을하고 넘겨야할지 db로 넘겨야할지 전혀 모르겠습니다................................. 이틀동안 찾아봐도 해결이 안되어서 질문 남깁니다..
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
배포 강의를 시작하시는 분들은 인스턴스 환경변수 분리까지 보신 후에 하시면 좋을 것 같습니다.
처음에 .env파일을 깃허브에 올리시길래 띠용했지만 곧바로 수정하시는군요.지금은 연습 중이라서 올라가도 크게 문제가 없을 것 같고, 또한, 강사님께서 .env가 깃허브에 올라갔을 때 어떻게 대처하는지 알려주시기 때문에 연습 용도로도 좋아보입니다..env파일을 올리는게 찜찜하신 분들은 인스턴스 환경변수 분리까지 보신 뒤에 하시는게 좋을 것 같고, 나는 .env가 노출 된 상황을 한 번 연습해보고 싶다. 하시는 분들은 차례대로 진행하는 것도 좋을 것 같습니다!
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
userRepositorySpySave 왜 ? 0 이 안나와? 는 보십시오.
```typescriptasync create({ email, password, mobileNumber }) { const user = await this.userRepository.findOne({ where: { email } }); if (user) throw new ConflictException('이미 등록된 이메일 입니다.'); return await this.userRepository.save({ email, password, mobileNumber }); }일때 findOne({ where: { email } }) { const users = this.mydb.filter((el) => el.email === email); if (users.length) return { ...users[0] }; return null; }입니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
1:1 관계 등록 API 강의 creatProduct 시 에러가 발생합니다
삽입시 address 값을 입력했는데도 default 값이 설정되어있지 않다고 에러가 뜹니다.
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
nest 실행 (npm run start:dev)이 너무 오래 걸려요
typescript 기초 강의에서 nest를 처음 실행했는데 실행 시 너무 오래 걸립니다..(약 20~30분 정도) windows os에서 실행 햇는데 이유가 있을까요?현재 컴퓨터 사양은 Memory 32G 에 RAM 16 Core 입니다.매번 이렇게 시간이 걸리면 현실적으로 test가 불가능해서 방법을 구하고자 합니다. +추가yarn으로 실행해봐도 비슷하네요..Windows OS에서 WSL 통해서 Ubuntu 환경에서 실행하고 있습니다.
-
해결됨탄탄한 백엔드 NestJS, 기초부터 심화까지
이 강의를 들을 때 필요한 언어공부가 있을까요? 추천 부탁드립니다,
제가 백엔드 공부도 처음이고 언어 공부에서도 c 이후로 는 거의 하지 않았습니다. 프로젝트 단계로 넘어가기 전 언어 공부를 해야 더 도움이 될거같은데 typescript 나 자바스크립트를 선행 언어 공부를 한 후에 들어야 도움이 더 잘 될까요? 아니면 공부 없이도 듣기 괜찮을 까요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
API-Gateway2 섹션 Apollo 서버 구동 에러
Auth와 Resource App 시작 시 아래 사진과 같은 에러가 발생합니다. 강의와 노션에 있는 코드를 그대로 작성했다고 생각하여 패키지 버전 문제로 추정됩니다.현재 제가 사용중인 패키지입니다.강의 중 사용중인 패키지 버전을 공유받고 싶습니다. 해당 오류에 대한 구글링에 실패해서 추가적으로 혹시 알고계신 레퍼런스 있으시면 알려주시면 감사드리겠습니다.
-
해결됨탄탄한 백엔드 NestJS, 기초부터 심화까지
'수업 노트를 확인해 주세요 :)'의 수업노트 위치가 어디인가요?
'첫 시작' 챕터 영상 레이아웃의 하단에 '수업 노트를 확인해 주세요 :)'가 있는데 해당하는 수업노트가 어디 있는건가요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
암호화/인증 & 인가 과제 중 질문
updateUserPwd 구현 중에, 파라미터로 업데이트할 패스워드를 받도록 했습니다. 이 때, API 호출 시, 해당 파라미터의 최소 길이를 8 이상으로 하고 싶은데 따로 방법이 있을까요?
-
미해결탄탄한 백엔드 NestJS, 기초부터 심화까지
안녕하세요 강의를 따라가던 중 한 번의 이벤트임에도 두 번이 발생합니다.
위에 이미지처럼 클라이언트에서 emit을 발생시켰을 때 서버에서 2번이 찍히고, username을 클라이언트로 전달해줄 때도, 클라이언트에서 2번이 찍힙니다. afterInit()함수 내부의 로거도 두번 작동하는데 왜 이럴까요?
-
해결됨[코드캠프] 부트캠프에서 만든 고농축 백엔드 코스
액세스토큰을 변수로 저장하면 생기는 문제점
안녕하세요. 강의중에 액세스토큰을 변수로 req.header에 저장하면 아래와 같이 3가지 문제점이 있다는 것을 구글링을 통해서 확인했습니다.1.보안: 액세스토큰을 req.header에 변수로서의 토큰은 공격자에 의해 가로채기에 취약합니다.2.확장성: 애플리케이션에 많은 수의 요청이 있는 경우 req.header의 변수는 크기가 커지고 성능 문제가 발생할 수 있습니다.3.지속성: req.header에 액세스 토큰을 저장하는 것은 영구적이지 않습니다. 사용자가 페이지를 새로 고치거나 브라우저를 닫으면 액세스 토큰이 손실됩니다. 이로 인해 사용자가 보호된 리소스에 액세스하기 위해 다시 로그인해야 할 수 있습니다. 질문1)3번 지속성문제의 경우, 브라우저를 새로고침하게 되면, 액세스 토큰이 사라지게 되니 오히려 보안이 좋다고 생각해야 할까요? accessToken이 수업에서는 10분으 로 만료기간을 설정했는데, restoreAccessToken API가 있기 때문에 acessToken을 req.header에 변수로 저장해도 문제가 되지 않을까요? 질문2)액세스토큰 만료시간을 10분 ~30분 으로 짧게 잡으신 이유가 1번 문제점 보안의 이유라고 생각하면 될까요? 질문3)선생님, 좋은 강의 해주셔서 진심으로 감사합니다. 저는 선생님의 백엔드와 프론트 강의를 수강후 실제 웹 서비스를 런칭하기위해서 수업을 듣고 있습니다. 현재는 백엔드 강의를 수강중입니다.실제 웹 서비스런칭시 accessToken을 req.header에 변수로서 저장하고, refreshToken은 쿠키에 저장하는 게 올바른 방법인가요?refreshToken을 수업에서 가르쳐주신 대로 secure : true, httponly: true와 같이 배포환경으로 바꿔서 배포하게 된다면 보안상 안전할까요? 질문4)구글링을 해보니, 리프레시 토큰을 Redis에 저장하고, 액세스토큰은 쿠키에 저장하는 방법도 있는 것을 확인했습니다. 액세스토큰의 만료기간을 10분으로 잡고, 리프레시토큰의 만료기간을 2주로 잡을 경우, restoreRefreshToken API 때문에 Redis DB에 자주 접속하게 되어서 DB 사용료가 많이 청구 되지는 않을까요? 서버를 stateless 상태로 웹 서비스를 런칭하기 위해서는 액세스토큰과 리프레시 토큰을 어떻게 저장해야 할까요? 가장 안전한 방법이라고 할 수 있을까요? 감사합니다.