본문 바로가기

개발/Nest.js4

02) Nest.js JWT인증 + RoleGuard 가이드 전체 코드 : https://github.com/jeounpar/nestjs-jwt-roleguard-tutorial 1. role-guard.decorator.ts 파일 생성 import { SetMetadata } from '@nestjs/common'; export const Roles = (...roles: string[]) => SetMetadata('roles', roles); @Role() 데코레이터로 사용된다. 2.auth.guard.ts 파일 수정 import { CanActivate, ExecutionContext, Injectable, UnauthorizedException, } from '@nestjs/common'; import { JwtService } from '@nestjs/.. 2023. 6. 9.
01) Nest.js JWT인증 + RoleGuard 가이드 전체 코드 : https://github.com/jeounpar/nestjs-jwt-roleguard-tutorial JWT란 무엇인가요? https://jwt.io/introduction JWT.IO JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties. jwt.io 1. nest 프로젝트 생성 및 auth 모듈 생성 $ nest new jwt-tutorial $ cd jwt-tutorial $ nest generate module auth $ nest generate service auth $ nest generate controller auth 2.. 2023. 6. 9.
Nest.js serverless + AWS Lambda 배포하기 소스코드 : https://github.com/jeounpar/nestjs-aws-lambda 1. nest 프로젝트 생성 $ nest new aws-lambda-test 2. serverless 모듈 설치 $ npm install -g serverless $ npm install --save aws-serverless-express aws-lambda $ npm install --save-dev serverless-plugin-typescript serverless-plugin-optimize serverless-offline plugin $ serverless plugin install -n serverless-plugin-warmup 3. aws credential 설정 $ vi ~/.aws/cre.. 2023. 3. 19.
Nest.js interface 구현체에 DI 적용하기 Nest.js 에서 interface는 컴파일 환경에서만 존재하고 런타임 환경에서는 사라지기 때문에 interface를 구현한 클래스는 Nest.js의 DI컨테이너가 해당 컨테이너를 찾지 못한다. 해결방법 // test.interface.ts export interface Test { getHello(): string; } // test-impl.service.ts import { Injectable } from '@nestjs/common'; import { Test } from './test.interface'; @Injectable() export class TestImpl implements Test { getHello(): string { return 'Hello World!'; } } // a.. 2023. 3. 13.