def create_api_gw()

in serverless/ivs_moderation/ivs_moderation_stack.py [0:0]


    def create_api_gw(self, backend, user_pool):
        """ Function to create api gateway """
        api_ep = api.LambdaRestApi(
            self, "ivs-moderation-api", handler=backend, proxy=False)

        # Attaching cognito auth for all API requests
        auth = api.CognitoUserPoolsAuthorizer(
            self, "apiauth", cognito_user_pools=[user_pool])

        # Creating root resource
        api_root_resource = api_ep.root.add_resource("api")
        api_root_resource.add_method(
            "GET", authorizer=auth, authorization_type=api.AuthorizationType.COGNITO)

        # Creating the channel resource
        api_resource = api_root_resource.add_resource("channel", default_cors_preflight_options={
            "allow_origins": api.Cors.ALL_ORIGINS,
            "allow_methods": api.Cors.ALL_METHODS
        })

        # Creating REST API Method "POST"
        api_resource.add_method("POST", authorizer=auth,
                                authorization_type=api.AuthorizationType.COGNITO)

        return api_ep