Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

[feature] add functions:invoke command #213

Merged
merged 2 commits into from
Jul 10, 2019
Merged

[feature] add functions:invoke command #213

merged 2 commits into from
Jul 10, 2019

Conversation

swyxio
Copy link
Contributor

@swyxio swyxio commented Jul 8, 2019

- Summary

this adds a new netlify functions:trigger command to help locally test functions before deploying. cutting down on the dev cycle. in particular, the event triggered functions can now be triggered locally and manually for fast testing.

functionstrigger

known todos:

  • the getPort strategy will fall apart with multiple running netlify dev instances. in case of ambiguity we might force the user to specify a port in future
  • need to go thru every event triggered function and confirm the response shape
  • more flexibility in terms of method, body, querystringparams, and headers (at what point do we just tell people to use Postman?)
  • is this useful in CI? must we have a plan to eliminate all prompts? biasing towards no for now but i know somebody's gonna ask this in future
  • (minor) the json.parse strategy i use is robust to non json formatted responses, however, it loses the formatting you'd get with response.json(). it makes the output look not as nice as it could be. how to do this right? (if you response.json() a non json response, it throws, despite having a try/catch).

- Description for the changelog

new command for locally testing all netlify functions

- A picture of a cute animal (not mandatory but encouraged)

image

@DavidWells
Copy link
Contributor

Looks cool!

I think we should be using standard serverless/lambda function terms like invoke

Interactive:

netlify functions:invoke
# show prompts

CI/scriptable context

# inline payload
netlify functions:invoke functionName --payload '{"foo": "bar"}'

# payload from file
netlify functions:invoke functionName --payload ./example.json

@swyxio
Copy link
Contributor Author

swyxio commented Jul 9, 2019

github didnt show notifications for this and i'm a bit worried i'm missing notifs. on it

@swyxio
Copy link
Contributor Author

swyxio commented Jul 9, 2019

flipped it to invoke and added the things

ntlinvoke

@swyxio swyxio changed the title [feature] add functions:trigger command [feature] add functions:invoke command Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants