본문 바로가기

분류 전체보기

(75)
무한스크롤 구현하기 Angular에서 Directive를 사용해서 무한 스크롤을 구현해보겠다. 무한 스크롤이란?유저에게 대용량 데이터를 한번에 가져와서 보여주려면 많은 시간이 걸린다.그래서 유저의 화면 영역을 채우는 데이터를 불러와 보여주고 스크롤을 내리면 그만큼의 데이터를 불러와서 보여주는 것을 의미한다. 1. 데이터를 가져와야 하는 시점 계산하기무한스크롤을 구현하기 위해서는 스크롤의 위치를 계산하는 것이 중요하다.문서의 높이와 현재 화면의 높이 등을 계산해서 데이터를 더 가져올 지를 선택해야 하기 때문이다. -  scrollHeight: 전체 문서의 높이-  innerHeight or clientHeight : 뷰포트의 높이-  scrollTop : 문서의 최상단부터 뷰포트의 최상단까지의 거리 |-------------..
[nestjs] Module이란, 순환 참조 오류 Error Nest can't resolve dependencies of the userscontroller (usersservice, ?). please make sure that the argument authservice at index [1] is available in the usersmodule context. 나의 경우 계속 이런 오류가 생겼다... 의존성 관계를 잘 파악하지 못해서 생긴 오류라는 생각이 들었고 Module을 어떻게 작성해야하는지를 찾아봤다. Module이란 각각의 기능을 담당하는 Controller와 Providers는 Module Decorator에 등록되고 이 각 기능 Module들을 App Module에 import하여 최종적으로 NestFactory로 create되는..
[nestjs] Authentication, bcrypt Login Authentication LifeCycle controller에 있는 @UseGuards가 사용자가 서버에 접속할 때, intercept해간다. LocalAuthGuard에 명시된 local이 local.strategy.ts를 사용한다. local.strategy에서는 validate method를 실행하고 이 과정에서 authService에 있는 validateUser method를 통해 비밀번호를 비교한다. 만약 비밀번호가 일치한다면, login controller가 실행되고 authService에 있는 login method가 실행된다. 참고한 블로그 https://docs.nestjs.com/security/authentication Documentation | NestJS - A p..
[Day7] Find Minimum in Rotated Sorted Array https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/ Find Minimum in Rotated Sorted Array - LeetCode Find Minimum in Rotated Sorted Array - Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the array nums = [0,1,2,4,5,6,7] might become: * [4,5,6,7,0,1,2] if it was rotated 4 times. * [0,1,2,4,5,6,7] if it leetcode.com 회전 배열에서 가장 작..
[Day6] Maximum Product Subarray https://leetcode.com/problems/maximum-product-subarray/ Maximum Product Subarray - LeetCode Maximum Product Subarray - Given an integer array nums, find a subarray that has the largest product, and return the product. The test cases are generated so that the answer will fit in a 32-bit integer. Example 1: Input: nums = [2,3,-2,4] Output: 6 Exp leetcode.com int형 배열이 있다. 그 배열의 서브배열 중 곱이 가장 큰 서브 배열..
static 이란, 쓰는 이유 JAVA에서의 메모리 공간 Static Area Java 파일은 field, constructor, method로 구분되는데, field에서 선언된 전역변수, static 변수[정적변수]를 static 영역에 저장한다. 그리고 Garbage Collector의 관리 영역 밖에 존재하므로 프로그램의 종료시까지 메모리가 할당된 채로 존재하므로 자주 사용하게 되면 시스템의 퍼포먼스에 악영향을 주게 된다. Stack Area method 내에서 정의하는 기본 자료형에 해당하는 지역변수의 데이터 값이 저장되는 공간으로 해당 메소드가 호출될 때, 메모리에 할당되고 종료되면 메모리가 해제된다. 이 영역은 LIFO의 구조를 갖고 새로운 데이터가 할당되면 이전 데이터는 지워진다. Heap Area Reference Ty..
const와 readonly의 차이 const const로 선언된 객체의 속성은 바꿀 수 있다. 즉, 재할당 가능과 객체의 속성 변경 가능은 서로 독립적인 내용이다. -> 컴파일 시 정해진 불변 값이며 프로그램이 종료될 때까지 변경할 수 없다. -> 상수는 기본적으로 static(정적)이다. 따라서 접근할 때 객체 필요없다. readonly TS에서 readonly 키워드를 통해 특정 속성의 변경을 막을 수 있다. type ReadOnlyType = { readonly prop: InnerType; } type InnerType = { innerProp: string; } const readonlyType: ReadonlyType = { prop: { innerProp: 'a' } } // readonlyType.prop.innerProp..
[error] NestJS [TypeOrmModule] Unable to connect to the database 해결방안 데이터베이스 비밀번호 설정 다시 synchronize 옵션 false로 변경 User 엔티티, UsersModel, UserRepository 등이 Module에 잘 들어갔는지 확인