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

Commit a12c694

Browse files
authored
document netlify functions:invoke
1 parent 6009a1c commit a12c694

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

README.md

+30-2
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,13 @@ $ netlify functions:create hello-world --url https://github.com/netlify-labs/all
201201
202202
**Deploying unbundled function folders**
203203
204-
Functions that have `node_modules` inside their own folders require these `node_modules` to be installed when deployed. For the time being, the Netlify build process does not recursively install dependencies for your function folders yet. So the recommended way to deploy these functions is to use the CLI command:
204+
Functions that have `node_modules` inside their own folders require these `node_modules` to be installed when deployed. For the time being, **the Netlify build process does not recursively install dependencies for your function folders yet**. So the recommended way to deploy these functions is to use the CLI command:
205205
206206
```
207207
netlify deploy --prod
208208
```
209209
210-
Opt out of the continuous deployment flow and use [zip-it-and-ship-it](https://github.com/netlify/zip-it-and-ship-it) instead. [Follow this issue for more updates](https://github.com/netlify/netlify-dev-plugin/issues/140).
210+
Or write a `prebuild` npm script yourself to `cd` into your function folders and install them yourself. We are hoping to improve this flow in future, [follow this issue for more updates](https://github.com/netlify/netlify-dev-plugin/issues/140).
211211
212212
**Writing your own Function Templates**
213213
@@ -232,6 +232,34 @@ Instead of using our basic templates, you can use your own by passing it with a
232232
233233
</details>
234234
235+
### Locally Testing Functions with `netlify functions:invoke`
236+
237+
`netlify functions:invoke` allows you to locally test functions going above and beyond a simple GET request in browser. (we only model POSTs now but could easily expand from here).
238+
239+
If you have Netlify Dev running your functions, you can then test sending payloads of data, or authentication payloads:
240+
241+
```bash
242+
243+
# with prompting
244+
netlify functions:invoke # we will prompt you at each step
245+
netlify functions:invoke myfunction # invoke a specific function
246+
netlify functions:invoke --name myfunction # invoke a specific function
247+
248+
# no prompting (good for CI)
249+
netlify functions:invoke --name myfunction --identity # invoke a specific function with netlify identity headers
250+
netlify functions:invoke --name myfunction --no-identity # invoke a specific function without netlify identity headers
251+
252+
# sending payloads
253+
netlify functions:invoke myfunction --payload "{"foo": 1}"
254+
netlify functions:invoke myfunction --querystring "foo=1
255+
netlify functions:invoke myfunction --payload "./pathTo.json"
256+
```
257+
258+
There are special cases for [event triggered functions](https://www.netlify.com/docs/functions/?utm_source=blog&utm_medium=netlifydev&utm_campaign=devex#event-triggered-functions) (eg `identity-signup`) which will also give you mock data for testing. This makes manual local testing of event triggered functions possible, which drastically improves the development experience.
259+
260+
This is a new feature; ideas and feedback and issues and PR's welcome!
261+
262+
235263
### Function Builders, Function Builder Detection, and Relationship with `netlify-lambda`
236264

237265
**Existing users of `netlify-lambda` should have no change to their workflow by switching to `netlify dev`.** One immediate benefit is no need for [proxying](https://github.com/netlify/netlify-lambda#proxying-for-local-development) since Netlify Dev does that for you.

0 commit comments

Comments
 (0)