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 되었다고 뜨는데 이 부분은 상관없나요? 이후 강의를 들으면서 따라가는데 차질이 생기는지 궁금합니다.
코드 관련 질문은 아래와 같이 '코드블럭' 기능을 이용해주세요! + 오류 메세지도 함께 올려주시면 좋아요 🙂 npm error code ENOENT npm error syscall open npm error path C:\Users\사용자이름\Desktop\animal_album_Main\animal_album-3\package.json npm error errno -4058 npm error enoent ENOENT: no such file or directory, open 'C:\Users\사용자이름\Desktop\animal_album_Main\animal_album-3\package.json' npm error enoent This is related to npm not being able to find a file. npm error enoent npm error A complete log of this run can be found in: C:\Users\사용자이름\AppData\Local\npm-cache\_logs\2024-12-06T08_26_22_967Z-debug-0.log 안녕하세요 질문드립니다 몇일동안 npm init 떄문에 질문드립니다 npm 설치시 해당 프로젝트 파일이 c드라이브 안에만 있어야 되는건가요 ? 1번 바탕화면에 프로젝트가 있을떄도 실행이 안됩니다 2번 c드라이브 -> User -> (사용자이름) -> github-> 해당 폴더 -> 프로젝트 폴더 3번 c드라이브 -> 프로젝트 폴더 3번일때만 되고 1,2번일때는 npm init 설치가 안되는데 2번도 가능하게 할려면 어떻게 해야하는지 궁금합니다