I Learned/TIL

[TIL] Nest.js 프로바이더와, React-Native 안드로이드 설정

beeimp 2022. 7. 8. 02:03

[TIL] Nest.js 프로바이더와, React-Native 안드로이드 설정

날짜

  • 2022.01.01

목표

  • Nest.js 학습

내용

Nest.js - Provider

  • Provider : 앱이 제공하는 핵심 기능인 비즈니스 로직 수행

    • Service, Repository, Factory, Helper 등
  • @injectable 데코레이터 사용

    • 다른 어떤 Nest 컴포넌트에서도 주입 가능해짐

      import { Injectable } from '@nestjs/common';
      
      @Injectable()
      export class UsersService {
        ...
      
      remove(id: number) {
        return `This action removes a #${id} user`;
      }
      }
  • 사용

      @Controller('users')
      export class UsersController {
        constructor(private readonly usersService: UsersService) {}
          ...
    
          @Delete(':id')
          remove(@Param('id') id: string) {
            return this.usersService.remove(+id);
          }
      }

React-Native - 안드로이드 설정

  • OS - macOS ( m1 )

  • 기본 설치

      # Node & Watchman
      $ brew install node
      $ brew install watchman
  • Java Development Kit

      $ brew tap homebrew/cask-versions
      $ brew install --cask zulu11
  • Android Studio 개발 환경 설정

    • Android SDK
    • Android SDK Platform
    • Android Virtual Device
  • SDK Platforms 설치

    • Appearance & Behavior → System Settings → Android SDK → Click ‘Show Package Details’
    • Android SDK Platform 31
    • ARM 64 v8a System Image
    • Google APIs ARM 64 v8a System Image
  • ANDROID_SDK_ROOT 환경 변수 설정

      $ export ANDROID_SDK_ROOT=$HOME/Library/Android/sdk
      $ export PATH=$PATH:$ANDROID_SDK_ROOT/emulator
      $ export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools
  • project 생성

      $ npx react-native init AwesomeTSProject # --template react-native-template-typescript
  • 서버 실행

      $ npx react-native start
  • 앱 실행

      $ npm run android

결론

  • API 31 버전이 기본으로 되어 있었고, m1이라 약간 설치가 달랐습니다. API 32 버전을 사용하고 arm 관련 설치 해주니 잘 동작했습니다.

참조링크