1

저는 서버리스 프레임 워크에 익숙하지 않습니다.서버리스 - 대형 앱

GET 사용자/{사용자 ID}

POST 사용자


GET 계정/{계정 아이디}

:

나는 예를 들어, 여러 라우팅을하는 나머지 API를 시작하고

POST 계정

계정 + 사용자가 2 개인 서비스가 필요합니까?

모범 사례는 무엇입니까? 2 서비스라면 2 serverless.yml? 어떤 사람이 서버가없는 큰 응용 프로그램에 대한 예를 가지고 있습니까?

감사합니다.

답변

1

정말 당신이 당신의 앱을 위해 원하는 아키텍처에 달려 있습니다. here을 보시면 제가 원하는 것이 무엇인지 결정하는 데 도움이 될 것이라고 생각합니다.

한 지점에 많은 엔드 포인트가있는 경우 자원 한도에 도달하기 때문에 2 개의 서비스가 필요할 수 있습니다. 앱에 대해 하나의 단일 URL을 원할 경우 언제든지 pathmapping을 설정할 수 있습니다.

resources: 
    Resources: 
    pathmapping: 
     Type: AWS::ApiGateway::BasePathMapping 
     Properties: 
     BasePath: <your base for this service> 
     DomainName: mydomain.com 
     RestApiId: 
      Ref: ApiGatewayRestApi 
     Stage: dev 
1

예를 들어 하나의 서비스 (serverless.yml)를 사용하면 충분합니다.

1 개의 서비스에서 1 개의 람다를 사용하여 usersaccounts 요청을 처리 할 수 ​​있습니다.

functions: 
    <your-function-name>: 
    handler: handler.execute 
    events: 
     - http: 
      path: /user/{userid} 
      method: get 
     - http: 
      method: post 
      path: /user  
     - http: 
      path: /account/{accountid} 
      method: get 
     - http: 
      method: post 
      path: /account 

또는 당신은 (개체 당 하나)

functions: 
    user: 
    handler: userHandler.execute 
    events: 
     - http: 
     path: /user/{userid} 
     method: get 
     - http: 
     method: post 
     path: /user 
    account: 
    handler: accountHandler.execute 
    events: 
     - http: 
     path: /account/{accountid} 
     method: get 
     - http: 
      method: post 
      path: /account 
2 람다를 만들 수 있습니다
관련 문제