Web

· Web/Nodejs
🎯 Goal global 옵션 없이 로컬에 설치한 패키지를 커맨드로 실행할 수 있다. 언제 쓰나? `npm install -g` 글로벌 옵션 없이 프로젝트 별로 설치된 node_modules 패키지를 CLI로 실행할 때 (주로, 프로젝트별로 버전을 따로 관리하고 사용하고 싶을 때) 예시 npx는 무료로 실행해줍니다. npx (option) [package_name (command)] (command_argument)... ex) npx pm2 restart server.js npx 는 어떻게 동작하나? 환경변수 `PATH`에 해당 커맨드이름이 존재하는지 확인한다. 로컬 프로젝트 디렉토리 내에서 패키지명과 동일한 binary 파일을 찾아본다. 존재하면 실행한다. 🔗 Reference How to use e..
· Web/Nodejs
When Create Custom Type? Program has complex data structures Basic tyeps (primitive types) don't describe completely the data structures I'm using When creating Library Cooperation with others and needing define new class, interface etc.. How To Make Custom Type Syntax? Use `type` keyword! How to use it smartly? 보통 `types.d.ts` 파일로 타입을 정의하는 것이 국룰이다. 1. *.d.ts 타입 정의 2. import {타입명} from '*.d.ts' ..
· Web
TL;DR; 2022-08-23 mkcert 라는 날먹 툴을 사용하면 localhost 에도 HTTPS 발급/적용이 가능합니다. localhost 도메인 기반의 호스팅시 인증서 발급/적용이 불가능합니다. (ex. http://localhost:3000) www.my-domain.com과 같은 형태의 도메인을 따로 발급받아야 정상적으로 SSL 를 발급/적용이 가능합니다. SSL 인증서의 필요성 HTTPS 를 사용하기 위해서는 SSL 인증서가 필요하고, 이 인증서 발급을 위해서 OpenSSL 를 설치해야함 설치 안하면 어떻게 되냐고? 다음은 nodejs + koa 를 이용한 https 서버 생성 코드다. import Koa, {Context, Request, Response, Next} from 'koa';..
· Web
필수 패키지 설치 > npm init --y > npm i koa > npm i --save-dev typescript ts-node nodemon @types/koa @types/node ## 이 부분은 Visual Studio Code Plugin을 사용하면 굳이 추가설치 하지 않아도 되긴한당. > npm i --save-dev eslint eslint-config-prettier @typescript-eslint/parse ts-node: 트랜스파일링을 파일(.js)로 생성하지 않고 바로 메모리단에서 수행해주는 착한 친구다. ※ 패키지명에 @types/ 가 붙은 것은 TypeScript를 지원하는 패키지로 구글링해서 npm 패키지가 나오면 존재하는 것이다.! 그냥 바로 설치해주도록 하자. npm '..
1. index ; condition ; operation 아주 오래된, index , condition 을 명시한 for loop은 언어 어디에나 쓰여왔다 가령 다음과 같은 코드다. const array = ['a', 'b', 'c', 'd', 5]; for(let i=0 : i < array.length; i++) { console.log(array[i]) // 모든 원소 순서대로 iteration } // 출력결과: a b c d 5 2. for .. in C++, Java, Kotlinm 언어등에서도 흔히 배열 loop에 많이 쓰는 형태다. const array = ['a', 'b', 'c', 'd', 5]; for(let alphabet in array) { console.log(alphabet..
When to use 배열에서 특정 값에 대한 최종 합계를 구할 때 구문 array.reduce(callback, [intitialValue]) callback 각 배열 요소를 순회하며 실행할 함수 reduce( callbackfn: (previousValue: T, currentValue: T, currentIndex: number, array: T[]) => T, initialValue: T): T; Parameter Description previousValue 이전까지의 순회 값 currentValue 이번 항목의 값 currentIndex 이번 순회 회차 수 (Optional) array 순회 대상 배열 (Optional) accumulator 누산기, 콜백의 return value 누적. in..
M_Falcon
'Web' 카테고리의 글 목록 (2 Page)