This repository was archived by the owner on Jun 9, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
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
- Development utilities for Netlify Functions.
7
+ JavaScript/TypeScript utilities for Netlify Functions.
8
8
9
9
## Installation
10
10
@@ -18,6 +18,8 @@ npm install @netlify/functions
18
18
19
19
To use On-demand Builders, wrap your function handler with the ` builder ` function.
20
20
21
+ _ With JavaScript:_
22
+
21
23
``` js
22
24
const { builder } = require (' @netlify/functions' )
23
25
@@ -31,6 +33,22 @@ const handler = async (event, context) => {
31
33
exports .handler = builder (handler)
32
34
```
33
35
36
+ _ With TypeScript:_
37
+ ``` ts
38
+ import { builder , Handler } from ' @netlify/functions'
39
+
40
+ const myHandler: Handler = async (event , context ) => {
41
+ return {
42
+ statusCode: 200 ,
43
+ body: JSON .stringify ({ message: " Hello World" }),
44
+ }
45
+ }
46
+
47
+ const handler = builder (myHandler )
48
+
49
+ export { handler }
50
+ ```
51
+
34
52
### TypeScript typings
35
53
36
54
This module exports typings for authoring Netlify Functions in TypeScript.
You can’t perform that action at this time.
0 commit comments