라이브러리 설치

$ npm i bcrypt
$ npm i -D @types/bcrypt

 

비밀번호 암호화하기

  async signUp(signUpRequestDto: SignUpRequestDto) {
    const { email, password } = signUpRequestDto;
    const user = new User();
    user.email = email;
    const hashedPassword = await bcrypt.hash(password, 10);
    user.password = hashedPassword;
    return await this.userRepository.save(user);
  }

 

saltround 를 .env 파일에서 호출하여 넣을 때

호출한 값의 데이터 타입 = string 이므로 아래와 같이 확인 절차를 걸쳐서 number 로 변환해주어야 한다.

const saltRounds = this.configService.get<string>('SALT_ROUNDS');
if (saltRounds === undefined) {
    throw new Error('SALT_ROUNDS is not defined in the configuration.');
}
const hashedPassword = await bcrypt.hash(password, parseInt(saltRounds));

 

 

signIn 을 할때는  아래 코드를 이용하여 입력된 패스워드와 DB에 저장된 패스워드가 일치하는지 확인

const passwordMatch = await bcrypt.compare(password, user.password);

 

 

자료출처

https://docs.nestjs.com/security/encryption-and-hashing

 

'프로그래밍 > TypeScript' 카테고리의 다른 글

[ TS ] DTO object 구현  (0) 2024.08.03
[ TS ] 불변객체 immutable 장점 / 단점 / 구현방법  (0) 2024.07.28
[ TS ] tsconfig.json 의 내용 정리  (0) 2024.06.08
[ TS ] 오버로딩  (0) 2024.05.09
[ TS ] Promise<void> 의미  (0) 2024.05.07

1. Github 에 로그인 한다.

2. 수정이 필요한 repository에 들어간다

3. Pull Requests 메뉴에 들어가서 잘못된 PR의  github의 주소를 확인

    예시) https://github.com/계정이름/레포지토리-이름/pull/8

4.  깃허브에 문의를 한다. 

    https://support.github.com/request

5. Remove data from a repository I own or control( https://support.github.com/request/remove-data )로 접속

6. Remove pull requests 클릭

7. 3 번에서 복사한 삭제할 pull request 주소를 입력하여 티켓을 생성

 

완전히 삭제되면 메일로 알람이 온다.

 

다음으로 할일은 잘 못 합쳐진 내용을 복구하기

만약에 develope 에 pr 해야할 것을 main 으로 하였다면

1. 로컬에서 main 으로 이동 git pull origin main 으로 동기화

2. git log 를 입력하여 커밋된 내용을 확인해서 PR 되기 바로 이전의 commit id 를 확인

3. git reset --hard  <commit id> 를 이용하여 바로 이전으로 되돌리기

4. git push origin main -f 를 이용하여 강제로 이전의 내용으로 덮어씌우기

 

너무 복잡해진다. pull request 를 할때 대상을 잘 지정하였는지 꼭 확인하자.

  • feat :  새로운 기능(feature) 추가
  • fix : 버그 수정
  • perf :  성능향상을 위한 코드 변경
  • refactor :  버그를 수정하지도 않고 새로운 기능을 추가하지도 않은 코드 변경  혹은 파일의 위치 변경/ 리팩토링
  • style :  코드 변경없이 여백, 들여쓰기 철자등을 수정,
  • test : test를 하기 위한 코드를 수정밑 추가
  • docs : 문서만 수정
  • chore :  코드 변경없이 설정을 변경(package.json, tsconfig.ts, 빌드 스크립트 수정 등등) 

Entity 관계를 수정했을 때?

- refactor: 엔티티 관계의 수정이 기존 기능에 영향을 주지 않으면서 코드의 설계나 내부 구조를 개선하기 위한 목적인 경우

- feat : 엔티티의 관계를 수정하는 것이 새로운 기능을 추가하거나 기존 기능의 동작 방식을 변경하는 경우

 

참고 자료

 

Conventional Commits

A specification for adding human and machine readable meaning to commit messages

www.conventionalcommits.org

 

 

angular/CONTRIBUTING.md at 22b96b96902e1a42ee8c5e807720424abad3082a · angular/angular

Deliver web apps with confidence 🚀. Contribute to angular/angular development by creating an account on GitHub.

github.com

 

 

[Git/Github] Commit Convention이란?

커밋 컨벤션에 대해 알아보자

kdjun97.github.io

 

코드 tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "declaration": true,
    "removeComments": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "target": "ES2021",
    "sourceMap": true,
    "outDir": "./dist",
    "baseUrl": "./",
    "incremental": true,
    "skipLibCheck": true,
    "strictNullChecks": true,
    "noImplicitAny": true,
    "strictBindCallApply": false,
    "forceConsistentCasingInFileNames": false,
    "noFallthroughCasesInSwitch": true,
    "strictFunctionTypes": true,
    "useUnknownInCatchVariables": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
  }
}
  • "module": "commonjs"  ▶ 생성될 모듈 코드 wlwjd
  • "declaration": true   ▶ 프로젝트 배포시 .d.ts 파일을 생성
  • "removeComments": true ▶ /*!로 시작하는 copy-right 헤더 주석을 제외한 모든 주석을 제거
  • "emitDecoratorMetadata": true ▶ 소스에 데코레이터 선언에 대한 설계-타입 메타 데이터를 내보냅니다.
  • "experimentalDecorators": true ▶ ES 데코레이터에 대한 실험적인 지원을 사용하도록 활성화합니다.
  • "allowSyntheticDefaultImports": true ▶  default export가 없는 모듈에서 default imports를 허용합니다. 코드 방출에는 영향을 주지 않으며, 타입 검사만 수행합니다
  • "target": "ES2021" ▶ JavaScript에 대한 버전을 설정합니다.
  • "sourceMap": true 해당하는 .map 파일을 생성합니다.
  • "outDir": "./dist" ▶ 컴파일된 파일들을 저장할 디렉토리를 지정합니다.
  • "baseUrl": "./" ▶ 상대 경로가 아닌 모듈이 기본적으로  위치한 기준 디렉토리를 설정합니다.
  • "incremental": true 프로젝트를 증분 컴파일할 수 있도록 .tsbuildinfo 파일을 저장합니다.
  • "skipLibCheck": true  모든 .d.ts 파일을 검사하는 형식을 건너뜁니다.
  • "strictNullChecks": true ▶ 엄격하게 null 과 undefined 타입을 허락하지 않는다.
  • "noImplicitAny": true ▶ any 타입으로 암시한 표현식과 선언에 오류를 발생시킵니다.
  • "strictBindCallApply": false ▶  함수에서 bindcall 그리고 apply 메서드의 더 엄격한 검사를 활성화합니다.
  • "forceConsistentCasingInFileNames": false 파일명에 대소문자 구분하지 않아도 되는 기능 사용 여부
  • "noFallthroughCasesInSwitch": true ▶ 스위치 문에 fallthrough cases에 대해 오류 보고를 사용하도록 설정합니다.
  • "strictFunctionTypes": true 함수를 할당할 때 매개 변수와 반환 값이 서브 타입과 호환되는지 확인합니다
  • "useUnknownInCatchVariables": true ▶ catch 절의 변수 유형을 any 대신 unknown으로 만듭니다.
  • "noImplicitReturns": true ▶ 함수의 모든 코드 경로에서 반환 값이 없을 때 오류를 보고합니다.
  • "noUnusedLocals": true ▶사용되지 않은 지역 변수에 대한 오류를 보고합니다.
  • "noUnusedParameters": true 사용되지 않은 매개변수에 대한 오류를 발생시킵니다

*증분컴파일 : 프로그램의 수정된 부분만 다시 컴파일하는 기술

 

참고자료

  1. https://typescript-kr.github.io/pages/compiler-options.html
  2. https://velog.io/@ez1211/tsconfig.json-%ED%95%9C%EA%B8%80-%EB%B2%88%EC%97%AD
  3. https://inpa.tistory.com/entry/TS-%F0%9F%93%98-%ED%83%80%EC%9E%85%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8-tsconfigjson-%EC%84%A4%EC%A0%95%ED%95%98%EA%B8%B0-%EC%B4%9D%EC%A0%95%EB%A6%AC
  4. https://velog.io/@ez1211/tsconfig.json-%ED%95%9C%EA%B8%80-%EB%B2%88%EC%97%AD

터미널에서 

1. .pem 이 있는 위치이동

2. SSH 연결 명령어입력

이 두 단계를 어느 경로에서든지 하나의 명령어로 실행하기

 쉘스크립트 작성

#xxx 에 원하는 이름 입력
$ touch xxx.sh

 

파일에 SSH 명령어 입력

$ vi xxx.sh
# xxx.sh
ssh -i "/.../.../temp/xxx-xxx-xx.pem" unbuntu@ec2-.....

  - .pem 이 있는 위치를 절대경로로 입력하고 ec2에 ssh 로 연결하는 명령어 입력
 -  절대경로로 입력하는 이유는 어디서든지 실행이 가능하도록 하기 위함

 

유저에게 생성된 스크립트에 대한 권한부여 

$ chmod 755 xxx.sh

- 유저에게는 모든 권한, 그외 유저는 읽기와 실행의 권한만 부여

 

실행하여서 작동확인

$ ./xxx.sh

 

alias 이용하여 명령어 생성

$ vi ~/.zshrc

### 편집모드

# Connect to EC2 instance
# alias 원하는명령어="{.sh 파일이 있는 절대경로}"
alias goEC2="{/.../.../xxx.sh}"

 

저장후 종료

 

변경된 사항 적용

$ source ~/.zshrc

'서버 & 웹 개발 노트 > AWS' 카테고리의 다른 글

[ AWS ] RDS 와 DBeaver 에 연결하기  (0) 2024.08.06
[ AWS ] RDS 사용하기  (0) 2024.08.06
[ AWS ] 간단한 배포 과정 정리  (0) 2024.08.05
[ aws ] mysql 설치하기  (0) 2024.05.29
[ AWS ] 용어 정리  (0) 2024.03.09

+ Recent posts