File tree 1 file changed +31
-4
lines changed
1 file changed +31
-4
lines changed Original file line number Diff line number Diff line change 4
4
[ ![ Coverage Status] ( https://codecov.io/gh/netlify/functions-js/branch/main/graph/badge.svg )] ( https://codecov.io/gh/netlify/functions-js )
5
5
[ ![ Node] ( https://img.shields.io/node/v/@netlify/functions.svg?logo=node.js )] ( https://www.npmjs.com/package/@netlify/functions )
6
6
7
- JavaScript utilities for Netlify Functions.
7
+ Development utilities for Netlify Functions.
8
8
9
9
## Installation
10
10
@@ -14,10 +14,12 @@ npm install @netlify/functions
14
14
15
15
## Usage
16
16
17
- ### Builder Functions
17
+ ### On-demand Builders
18
+
19
+ To use On-demand Builders, wrap your function handler with the ` builder ` function.
18
20
19
21
``` js
20
- const { builderFunction } = require (' @netlify/functions' )
22
+ const { builder } = require (' @netlify/functions' )
21
23
22
24
const handler = async (event , context ) => {
23
25
return {
@@ -26,9 +28,34 @@ const handler = async (event, context) => {
26
28
}
27
29
}
28
30
29
- exports .handler = builderFunction (handler)
31
+ exports .handler = builder (handler)
30
32
```
31
33
34
+ ### TypeScript typings
35
+
36
+ This module exports typings for authoring Netlify Functions in TypeScript.
37
+
38
+ ``` ts
39
+ import { Handler } from ' @netlify/functions'
40
+
41
+ const handler: Handler = async (event , context ) => {
42
+ return {
43
+ statusCode: 200 ,
44
+ body: JSON .stringify ({ message: " Hello World" })
45
+ }
46
+ }
47
+
48
+ export { handler }
49
+ ```
50
+
51
+ The following types are exported:
52
+
53
+ - ` Handler `
54
+ - ` HandlerCallback `
55
+ - ` HandlerContext `
56
+ - ` HandlerEvent `
57
+ - ` HandlerResponse `
58
+
32
59
## Contributors
33
60
34
61
Please see [ CONTRIBUTING.md] ( ./CONTRIBUTING.md ) for instructions on how to set up and work on this repository. Thanks
You can’t perform that action at this time.
0 commit comments