Package Exports
- @netlify/functions
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@netlify/functions) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
JavaScript and TypeScript utilities for Netlify Functions.
Installation
npm install @netlify/functionsUsage
On-demand Builders
To use On-demand Builders, wrap your function handler with the builder function.
With JavaScript:
const { builder } = require('@netlify/functions') const handler = async (event, context) => { return { statusCode: 200, body: JSON.stringify({ message: 'Hello World' }), } } exports.handler = builder(handler)
With TypeScript:
import { builder, Handler } from '@netlify/functions' const myHandler: Handler = async (event, context) => { return { statusCode: 200, body: JSON.stringify({ message: 'Hello World' }), } } const handler = builder(myHandler) export { handler }
TypeScript typings
This module exports typings for authoring Netlify Functions in TypeScript.
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:
HandlerHandlerCallbackHandlerContextHandlerEventHandlerResponse
Contributors
Please see CONTRIBUTING.md for instructions on how to set up and work on this repository. Thanks for contributing!
