Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/netlify/functions
JavaScript and TypeScript utilities for Netlify Functions.
https://github.com/netlify/functions
aws functions javascript lambda-functions netlify netlify-functions netlify-lambda netlify-lambda-functions nodejs production serverless typescript
Last synced: 6 days ago
JSON representation
JavaScript and TypeScript utilities for Netlify Functions.
- Host: GitHub
- URL: https://github.com/netlify/functions
- Owner: netlify
- License: mit
- Created: 2021-02-22T12:35:13.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-23T01:44:24.000Z (20 days ago)
- Last Synced: 2024-12-30T01:10:50.436Z (13 days ago)
- Topics: aws, functions, javascript, lambda-functions, netlify, netlify-functions, netlify-lambda, netlify-lambda-functions, nodejs, production, serverless, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@netlify/functions
- Size: 2.59 MB
- Stars: 42
- Watchers: 9
- Forks: 17
- Open Issues: 26
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
- awesome - functions - Playground repo for Netlify’s Lambda Functions (HTML)
README
# ![functions](functions.png)
[![Build](https://github.com/netlify/functions/workflows/Build/badge.svg)](https://github.com/netlify/functions/actions)
[![Node](https://img.shields.io/node/v/@netlify/functions.svg?logo=node.js)](https://www.npmjs.com/package/@netlify/functions)JavaScript and TypeScript utilities for [Netlify Functions](https://docs.netlify.com/functions/overview/).
## Installation
```
npm install @netlify/functions
```## Usage
### On-demand Builders
To use On-demand Builders, wrap your function handler with the `builder` function.
- With JavaScript:
```js
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:
```ts
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 }
```### Scheduled Functions (currently in beta)
To use Scheduled Functions, wrap your function handler with the `schedule` function.
- With JavaScript:
```js
const { schedule } = require('@netlify/functions')exports.handler = schedule('5 4 * * *', async () => {
console.log("It's 04:05 AM!")
})
```- With TypeScript:
```ts
import { schedule } from '@netlify/functions'export const handler = schedule("5 4 * * *", async () => {
console.log("It's 04:05 AM!")
})
```### 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
for contributing!