[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요 선생님. 질문이 있습니다! @CreateDateColumn({ name: 'mb_regs_tm', type: 'timestamp', comment: '등록일시', }) regs_tm: Date; @UpdateDateColumn({ name: 'mb_mod_tm', type: 'timestamp', nullable: true, comment: '수정일시', }) mod_tm: Date; 위 데코레이션으로 만든 컬럼은 따로 시간을 지정해주지 않다보니 자동으로 UTC로 값이 설정되는데요. 문제는 @Column({ name: 'mb_exp_tm', type: 'timestamp', nullable: true, comment: '만료일시', }) exp_tm: Date; 이 컬럼의 경우 export function getExpirationDate(days: number): Date { const now = new Date(); return new Date(now.setDate(now.getDate() + days)); } 위의 함수를 사용하여 데이터가 생성된 날로부터 90일을 더한 값으로 만료일을 설정하거든요. 근데 mb_exp_tm 컬럼만 KST로 설정되고 나머지 mb_regs_tm, mb_mod_tm는 UTC로 데이터가 저장됩니다. https://github.com/typeorm/typeorm/issues/5841 위 이슈에서도 제가 현재 고민하고 있는 부분에 대해 얘기하고 있지만 명확한 답은 아직 찾질 못해서요. 혹시 위 문제에 대한 해결책을 들을 수 있을까요?
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
@Get(':commentId') getComment(@Param('commentId', ParseIntPipe) commentId: number) { return this.commentsService.getCommentById(commentId); } 안녕하세요 코드팩토리님해당 강의 듣는중 CommentController의 getComment 메서드에서 분명 특정 post의 특정 comment를 가져와야할거같은데 보면 commentId로만 조회하는걸로 보여집니다.제가 이해하지 못하고 의도를 파악하지 못한건지 반대인지 확인이 필요해보입니다. 상기는 해당 문제되어 보여지는 코드입니다. 강의에서는 postman을 사용해 해당 엔드포인트로 요청하는 장면이있는데 postId에 152? 게시글ID 값을 넣어서 조회하는데 코드대로면 의미가 없어보입니다. 감사합니다.
ASP.NET Core MVC +ASP.NET Core +REST API +.NET 8.0
11강 따라하다가 상단에 using System.Data .SqlClient; 설치도 잘 돼서 선언도 됐는데 using (SqlConnection sqlConnection = new SqlConnection(connectionString)) 이부분에 경고 CS0618 'SqlConnection'은(는) 사용되지 않습니다. 'Use the Microsoft.Data .SqlClient package instead.' 이런 경고가 나옵니다. 이것을 어떻게 수정해야 하나요?
안녕하세요 ! 해당 강의를 듣고 기능은 비슷한데 내용은 조금 다른 홈페이지를 제작해보고 싶어져서 질문 드립니다 ! API를 호출하는 기능은 이해했는데, 강사님이 만드신 API 처럼 저도 직접 간단한 정보를 담은 api 를 만들어보고 싶은데 이 부분은 어떻게 제작하는 지 알 수 있을까요?!
ASP.NET Core MVC +ASP.NET Core +REST API +.NET 8.0
EF로 생성해서 개발서버에 올려놓았는데, 첫 로딩속도가 많이 느리네요. 개발사이트에 출근해서 접속하거나, IIS의 응용프로그램풀을 재시작후에 접근하면 5~6초 정도 걸립니다. 하지만 일단 연결이 되고 나면, 이후에는 1초 이내에 응답이 바로바로 옵니다. 접근도메인이 문제인가 싶어서, IP로 바꾸어도 동일하네요. 이런 현상이 나타나는 이유와, 해결 방법을 알고 싶습니다.
안녕하세요 citiList 에 더보기 버튼이 있는데 handleLoadMore 함수가 더보기 버튼을 클릭했을 때 동작하는 함수인 것 이해했습니다. 근데 해당함수는 citiList 컴포넌트에서만 사용하니까 CitiList.js 에 작성할것으로 예상했는데 App.js 에 작성하셔서 App.js 에서 작성하고 CitiList 로 전달하는 이유가 궁금합니다!
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요 코드팩토리님 NestJS에 관심이 생겨 최근 강의를 듣고 있습니다. OneToOne 에서 onDelete 설정을 했을 때 계속 profile이 null 값으로만 변경되는데 제 코드에 문제가 있는지 궁금합니다. 검토 한 번 부탁드려요. 감사합니다!! // user.entity.ts export class UserModel { // 자동으로 ID 생성 @PrimaryGeneratedColumn() id: number; @Column() email: string; @Column({ type: 'enum', enum: Role, default: Role.USER, }) role: Role; // 데이터가 생성되는 날짜와 시간이 자동으로 찍힌다. @CreateDateColumn() createdAt: Date; // 데이터가 업데이트되는 날짜와 시간이 자동으로 찍힌다. @UpdateDateColumn() updatedAt: Date; // 데이터가 업데이트 될 때마다 1씩 올라간다. // 처음 생성되면 값은 1이다. // save() 함수가 몇번 불렸는지 기억한다. @VersionColumn() version: number; @Column() @Generated('uuid') additionalId: string; ////////////// 이 부분 ///////////// @OneToOne(() => ProfileModel, (profile) => profile.user, { // find() 실행 할 때마다 항상 같이 가져올 relation을 정할 수 있다. eager: true, // 저장할 때 relation을 한번에 같이 저장 가능하게 한다. cascade: true, // null 값이 가능하게 한다. nullable: true, // on: ~했을 때 // 관계가 삭제 됐을 때 // no action => 아무것도 안함 // cascade => 참조하는 Row도 같이 삭제 // set null => 참조하는 Row에서 참조 id를 null로 변경 // set default => 기본 세팅으로 설정 (테이블의 기본 세팅) // restrict => 참조하고 있는 Row가 있는 경우 참조 당하는 Row 삭제 불가 onDelete: 'RESTRICT', }) profile: ProfileModel; ////////////// 이 부분 ///////////// @OneToMany(() => PostModel, (post) => post.author) posts: PostModel[]; } // app.controller.ts import { Controller, Delete, Get, Param, Patch, Post } from '@nestjs/common'; import { InjectRepository } from '@nestjs/typeorm'; import { Role, UserModel } from './entity/user.entity'; import { Repository } from 'typeorm'; import { ProfileModel } from './entity/profile.entity'; import { PostModel } from './entity/post.entity'; import { TagModel } from './entity/tag.entity'; @Controller() export class AppController { constructor( @InjectRepository(UserModel) private readonly userRepository: Repository<UserModel>, @InjectRepository(ProfileModel) private readonly ProfileRepository: Repository<ProfileModel>, @InjectRepository(PostModel) private readonly PostRepository: Repository<PostModel>, @InjectRepository(TagModel) private readonly TagRepository: Repository<TagModel>, ) {} @Get('users') getUsers() { // OntToOne에 eager: true 설정을 하면 relations 옵션을 여기에서 넣어주지 않아도 된다. return this.userRepository.find({}); } @Delete('user/profile/:id') async deleteProfile(@Param('id') id: string) { await this.ProfileRepository.delete(+id); } @Post('user/profile') async createUserAndProfile() { const user = await this.userRepository.save({ email: 'asdf@naver.com', profile: { profileImg: 'asdf.jpg', }, }); // cascade: true 설정을 하면 relation을 한번에 같이 저장하게 되서 더 이상 두번 save 할 필요가 없음 // const profile = await this.ProfileRepository.save({ // profileImg: 'asdf.jpg', // user, // }); return user; } }
[개정판 2023-11-27] Spring Boot 3.x 를 이용한 RESTful Web Services 개발
현재 GIT에 올리신 소스를 실행해봤습니다. 그런데 시큐리티 비밀번호가 콘솔창에 뜨지 않습니다. 그리고 application.yml에서 시큐리티 관련 비밀번호 주석을 풀고 실행을 해도, rest api가 인증 없이도 호출되는 것 같습니다. 어떤 부분에서 설정이 빠진 것일까요?
초기값이 '' 이여서 강의에서는 value 값을 맨뒤로 넣고 input 태그에 닫힘을 작성하지 않음으로, 동작하게 하였는데 다른 방법으로는 <input type="text" placeholder="Search" id="search" value="${searchWord}" autocomplete="off"/> 로 작성하였습니다, value 를 싱글쿼터나 더블쿼터로 감싼다음 ${} 를 사용하시면, 뒤에다가 다른 속성을 넣거나 닫아도 정상 동작합니다. 참고 하실분 참고하셔도 좋습니다.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
안녕하세요 basic, bearer 토큰을 이미 범용적으로 널리 사용된다고 하셨는데 궁금한점이 로그인할 때 id/pw 를 header 에 넣어서 보낸다고 하셨는데 패킷을 탈취하면 너무 취약할 것 같아서요. 제가 웹개발자가 아니라 실무에선 실제로 어떻게 쓰는지 알고싶어서 질문남깁니다.
[코드팩토리] [초급] NestJS REST API 백엔드 완전 정복 마스터 클래스 - NestJS Core
강의 내용처럼 그대로 따라 했을 때 다음과 같이 됩니다. 1. 아래 사진 처럼 breakpoint 설정 시 빨간색이 아니라 빈원이 나옵니다. 실제 실행하였을 경우 break가 걸리긴 하는데 ts파일이 아닌 compile된 js 파일로 넘어갑니다. 인터넷 찾아보고 sourceMap 관련된거 같아서 tsconfig 파일에 sourceMap: true 넣고 launch.json에 sourceMaps: true 넣어봤는데도 변함이 없네요 어떤 부분을 확인해봐야할까요?
혹시나 기본 '/' 경로에서 펭귄눌렀다 popstate 로 뒤로갔을 경우 'clicked' css가 먹지않는 현상, 강의 내용에서 저부분이 영상 짤려서 놓치기 쉬울꺼 같습니다. 저도 강의보면서 하다가 || 'all' 하는 부분 제대로 보기힘들어서 못 적었다가 나중에 문제생겨서 로직 보다가 발견했습니다,
docker-compose build가 안되요!ㅠㅠㅠㅠㅠ 도커라 도커컴포즈 삭제하고 다시 까는거는 5시간동안 했는데... 챗gpt가 하라는데로 5시간동안 했는데 해결이 안되네요! Traceback (most recent call last): File "urllib3/ connectionpool.py ", line 677, in urlopen File "urllib3/ connectionpool.py ", line 426, in make request File "<string>", line 3, in raise_from File "urllib3/ connectionpool.py ", line 421, in make request File "http/ client.py ", line 1369, in getresponse File "http/ client.py ", line 310, in begin File "http/ client.py ", line 271, in read status File " socket.py ", line 589, in readinto ConnectionResetError: [Errno 104] Connection reset by peer During handling of the above exception, another exception occurred: Traceback (most recent call last): File "requests/ adapters.py ", line 449, in send File "urllib3/ connectionpool.py ", line 727, in urlopen File "urllib3/util/ retry.py ", line 410, in increment File "urllib3/packages/ six.py ", line 734, in reraise File "urllib3/ connectionpool.py ", line 677, in urlopen File "urllib3/ connectionpool.py ", line 426, in make request File "<string>", line 3, in raise_from File "urllib3/ connectionpool.py ", line 421, in make request File "http/ client.py ", line 1369, in getresponse File "http/ client.py ", line 310, in begin File "http/ client.py ", line 271, in read status File " socket.py ", line 589, in readinto urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "docker/api/ client.py ", line 214, in retrieve server_version File "docker/api/ daemon.py ", line 181, in version File "docker/utils/ decorators.py ", line 46, in inner File "docker/api/ client.py ", line 237, in _get File "requests/ sessions.py ", line 543, in get File "requests/ sessions.py ", line 530, in request File "requests/ sessions.py ", line 643, in send File "requests/ adapters.py ", line 498, in send requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "docker-compose", line 3, in <module> File "compose/cli/ main.py ", line 81, in main File "compose/cli/ main.py ", line 200, in perform_command File "compose/cli/ command.py ", line 70, in project_from_options File "compose/cli/ command.py ", line 153, in get_project File "compose/cli/docker_ client.py ", line 43, in get_client File "compose/cli/docker_ client.py ", line 170, in docker_client File "docker/api/ client.py ", line 197, in init File "docker/api/ client.py ", line 222, in retrieve server_version docker.errors.DockerException: Error while fetching server API version: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) [119730] Failed to execute script docker-compose 챗 gpt에 물어보고 똑같이 해봐도 해결이 안됩니다. ㅜㅜㅜㅜㅜ
현재 실무에서 ORM(Prisma)을 채택해서 백엔드를 만들고 있어요. ORM으로 할 수록 Repository패턴과 조합이 좋지않다고 생각이 들고 실제 팀리더도 Repository패턴을 같이 쓰는거에 부정적이고 실제로 사용하지 않아요. 그렇다고 service 하나에 몰아 넣으니 저는 코드 읽기가 점점 힘들어지는거 같아요. 대체할만한걸 검색해보니 CQRS패턴이나 Query Object가 나오는데 아니면 서비스파일을 여러개 두거나... 강사님 같은 경우에는 실무에서 어떻게 대처하시는지 궁금합니다.
ASP.NET Core MVC +ASP.NET Core +REST API +.NET 8.0
SqlConnection이 deprecated 되었다고 뜨는데 이 부분은 상관없나요? 아니면 제가 잘못...선택을 한건지...ㅠqlConnection이 deprecated 되었다고 뜨는데 이 부분은 상관없나요? 이후 강의를 들으면서 따라가는데 차질이 생기는지 궁금합니다.