serverless / serverless-google-cloudfunctions

Serverless Google Cloud Functions Plugin – Adds Google Cloud Functions support to the Serverless Framework
https://www.serverless.com
MIT License
272 stars 127 forks source link

feat: Add support for http events in invoke local #264

Closed CorentinDoue closed 3 years ago

CorentinDoue commented 3 years ago

Description

This pull request follows https://github.com/serverless/serverless-google-cloudfunctions/pull/258 and adds the implementation of the command invoke local for HTTP events from the google provider.

Implementation

Cloud functions triggered by HTTP use express 4.17.1.

  1. Default req and res are recreated as they are provided by express to the handler in the cloud
  2. The content of req is overridden by the data provided for the local execution
  3. The end method of res is overridden by a custom method to
    1. prevent the default behavior of end (send back the response to the client)
    2. get the body of the response to logging it
    3. end the local invocation

Tests

Next steps

CorentinDoue commented 3 years ago

cc @pgrzesik