Coder Social home page Coder Social logo

mini-board's People

Contributors

darkenpeng avatar

Stargazers

 avatar

Watchers

 avatar

mini-board's Issues

database, ORM 선택하기

백엔드끼리 논의할 내용입니다.

이전 맥락

참고 이전에 typeORM + postgre(supabase)를 쓰는 걸 한 번 꺼낸 적이 있습니다!

이유

  • 둘 다 서버를 오랫동안 (추정 N달간?) 열 계획이므로 비용 문제를 고려해야함
  • EC2를 열었을 때 DB가 원활하게 동작하려면 RAM 사양이 최소 8GB 정도 되어야하는데 코어가 추가되는것/램의 사양에 따라 금액이 커지므로 DB 서버와 분리해야 한다는 생각을 하게 됨.
  • 시간에 따라 비용을 산출하는 것이 아닌 api 호출 수 만큼 금액을 산정하는 serverless를 고려하게 됨
  • 이때 무료로 postgre를 이용할 수 있는 supabase가 존재함.
  • 후보로 두고 있는 typeORM도 postgreSQL을 지원함.

배포 환경 정하기

  • 백엔드 코드를 배포할 클라우드 인스턴스 알아보기(예시 : AWS Lambda)
  • 프론트엔드 코드 배포 알아보기(예시 : Netlify, cloudflares, )

이유와 함께 적어주세요!

반환 타입이 생각과 다릅니다.


userDTO

export class UserDto {
  readonly email: string;
  readonly password: string;
  readonly username: string;
}

UserEntity

abstract class CommonEntity {
  _id: string;
  createdAt: Date;
  updatedAt: Date;
}
export class UserEntity extends CommonEntity {
  email: string;
  username: string;
  password: string;
  imgUrl?: string;
}
// src/users.repository
  async getOneByEmail(email: string): Promise<UserDto> {
    const test = await this.userModel.findOneBy({ email });
    return test;
  }

repository 의 getOneByEmail에서 Promise면 UserEntity 보다 프로퍼티가
_id cratedAt updateAt세 개 적기 때문에 반환이 안되어야 한다고 생각하는데 response 가 밑처럼 나옵니다

// GET /users
    {
        "_id": 1,
        "createdAt": "2022-12-08T01:31:47.740Z",
        "updatedAt": "2022-12-08T01:31:47.740Z",
        "email": "[email protected]",
        "username": "gune",
        "password": "$2b$10$UvrtZ0J.GSJYbFhBArhBU.zISxoazYZ22wU3dAQ7cuLIeDJ2fainm",
        "imgUrl": null
    },

도움을 구합니다...

postService test 작성

POST API service unit test 작성 시 혼동되는 부분이 있어 공유합니다.

  • integration test <-> unit test의 차이
  • test DB가 없는 경우 어떻게 service를 테스트 해야하는지 의문 참고한 자료 - e2e테스트 아닌지 헷갈리는 상태임
  • service는 controller와 repository의 중간 역할인데 spyOn으로 구현하게 되면 실제 service가 어떻게 동작하는지 테스트하는 것이 아니게 됨.

생각해본 방법

  1. fakeDB를 만든다(?)
  2. test DB를 파서 e2e같은 integration test를 한다(?)

Authorization

권한에 따른 인가 구현하기 (jwt guard, strategy)

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.