Giter Site home page Giter Site logo

customfield-nestjs-example's Introduction

-

👋 Hi, Argon1025(Neo)
Back-end Developer, NodeJS
Blog · Email








customfield-nestjs-example's People

Contributors

argon1025 avatar

Watchers

 avatar  avatar

customfield-nestjs-example's Issues

전체 서비스 리팩터링

  • 올바른 역할과 책임이 부여되었는지
  • 관심사 분리가 되었는지
  • 불필요한 코드 베이스가 있는지

상점 커스텀 필드 관리

엔드포인트

  • PUT /store/:storeId/customer/:customerId
    • 유저의 정보를 수정합니다
    • (커스텀필드 ID, 유저아이디, 콘텐츠) 받아서 upsert(CustomerCustomfield -> customFieldId, Customer)로 갱신/생성

추가 되어야하는 로직

  • 커스텀필드에 onlyAdmin 컬럼을 추가합니다
  • onlyAdmin: true인 경우 관리자만 추가/수정이 가능한 컬럼입니다
  • 유저 생성시엔 onlyAdmin : true 커스텀 필드는 데이터 유효성 검사, 생성에서 제외합니다

prisma 구성

  • prisma 패키지 추가
  • 환경변수 및 실행 스크립트추가
  • package.json 실행 스크립트

프로젝트 개발환경 구성

프로젝트 개발환경 구성

  • package.json 작성
  • tsConfig 설정
  • ESLint Airbnb rule 설정
  • 개발환경 Docker-compose 구성

관리자, 상점 도메인

로직

필요한 기타 작업

  • admin, Store 테이블 생성
  • prisma 마이그레이션 작성
  • 더미데이터 삽입

프로젝트 구성

프로젝트 구성

  • exceptionFilter
  • swagger
    • nest-cli
  • configService
  • class-validation
  • Serialization

커스텀필드 수정

origin

  • 불가

name

  • 가능

require

  • 불가, 기존 생성 데이터와 정합성이 깨짐

fieldType

  • 불가, Enum, Default, 기존생성 데이터와 정합성이 깨짐

isArray

  • 불가, Default, 기존생성 데이터와 정합성이 깨짐

Enum

  • 추가만 가능, default, 기존생성 데이터와 정합성이 깨짐

리팩터링

관심사 분리

  • 값을 검증하는 custom-field 서비스에 상세 로직을 구성
  • 각 도메인안 customer-custom-field 서비스에서 해당 로직을 사용해서 값 검증 로직을 작성
  • customer에서 해당 값 검증 로직을 사용

리팩터링 요소

  • DTO readonly
  • DTO 모든 타입 문자열, 배열 제한
  • 재사용가능한 펑션으로 서비스 내부로직 대체
  • isStoreOwner로 내부로직 대체
  • 커스텀필드 수정시 커스텀필드 주인이 누군지 확인이 필요
  • 유저정보 조회시 커스텀필드의 이름도 전달

커스텀필드 삭제

  • 소프트 딜리트 기준

영향을받는 로직

  • 커스텀필드 생성, 수정
    • 삭제된 커스텀필드는 수정이 불가능하도록 한다
  • 커스텀필드 참고한 다양한 커스텀필드 테이블 서비스
    • 삭제된 커스텀필드는 이후 조회시 보이지 않도록한다

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.