From caa2062d58db3d8cbc14cde9da35c67628fa5241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eduardo=20Bou=C3=A7as?= Date: Tue, 13 Apr 2021 14:53:45 +0100 Subject: [PATCH] chore: update README --- README.md | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cf0e632a..52d3b4a9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Coverage Status](https://codecov.io/gh/netlify/functions-js/branch/main/graph/badge.svg)](https://codecov.io/gh/netlify/functions-js) [![Node](https://img.shields.io/node/v/@netlify/functions.svg?logo=node.js)](https://www.npmjs.com/package/@netlify/functions) -JavaScript utilities for Netlify Functions. +Development utilities for Netlify Functions. ## Installation @@ -14,10 +14,12 @@ npm install @netlify/functions ## Usage -### Builder Functions +### On-demand Builders + +To use On-demand Builders, wrap your function handler with the `builder` function. ```js -const { builderFunction } = require('@netlify/functions') +const { builder } = require('@netlify/functions') const handler = async (event, context) => { return { @@ -26,9 +28,34 @@ const handler = async (event, context) => { } } -exports.handler = builderFunction(handler) +exports.handler = builder(handler) ``` +### TypeScript typings + +This module exports typings for authoring Netlify Functions in TypeScript. + +```ts +import { Handler } from '@netlify/functions' + +const handler: Handler = async (event, context) => { + return { + statusCode: 200, + body: JSON.stringify({ message: "Hello World" }) + } +} + +export { handler } +``` + +The following types are exported: + +- `Handler` +- `HandlerCallback` +- `HandlerContext` +- `HandlerEvent` +- `HandlerResponse` + ## Contributors Please see [CONTRIBUTING.md](./CONTRIBUTING.md) for instructions on how to set up and work on this repository. Thanks