@netlify/functions
JavaScript utilities for Netlify Functions
Last updated 5 years ago by eduardoboucas .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @netlify/functions 
SYNC missed versions from official npm registry.

functions

Build Node

JavaScript and TypeScript utilities for Netlify Functions.

Installation

npm install @netlify/functions

Usage

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 }
    

Scheduled Functions (currently in beta)

To use Scheduled Functions, wrap your function handler with the schedule function.

  • With JavaScript:

    const { schedule } = require('@netlify/functions')
    
    exports.handler = schedule('5 4 * * *', async () => {
      console.log("It's 04:05 AM!")
    })
    
  • With TypeScript:

    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.

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 for instructions on how to set up and work on this repository. Thanks for contributing!

Current Tags

  • 2.0.1-beta                                ...           beta (4 years ago)
  • 0.7.3-handle-secrets.2                                ...           handle-secrets (5 years ago)
  • 1.6.0                                ...           latest (3 years ago)
  • 1.2.0-rc                                ...           rc (4 years ago)
  • 0.7.3-streaming.12                                ...           streaming (5 years ago)

46 Versions

  • 1.6.0                                ...           3 years ago
  • 1.5.0                                ...           3 years ago
  • 1.4.0                                ...           3 years ago
  • 1.3.0                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.2.0-rc                                ...           4 years ago
  • 2.0.1-beta                                ...           4 years ago
  • 2.0.0-beta                                ...           4 years ago
  • 1.1.0-rc                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.11.1                                ...           4 years ago
  • 0.11.0                                ...           4 years ago
  • 0.11.0-rc                                ...           4 years ago
  • 0.10.0                                ...           4 years ago
  • 0.9.1-beta                                ...           4 years ago
  • 0.9.0                                ...           4 years ago
  • 8.0.1-beta.1                                ...           4 years ago
  • 0.8.1-beta.0                                ...           4 years ago
  • 0.8.0                                ...           4 years ago
  • 0.7.3-streaming.12                                ...           5 years ago
  • 0.7.3-streaming.11                                ...           5 years ago
  • 0.7.3-streaming.10                                ...           5 years ago
  • 0.7.3-streaming.9                                ...           5 years ago
  • 0.7.3-streaming.8                                ...           5 years ago
  • 0.7.3-streaming.7                                ...           5 years ago
  • 0.7.3-streaming.6                                ...           5 years ago
  • 0.7.3-streaming.5                                ...           5 years ago
  • 0.7.3-streaming.4                                ...           5 years ago
  • 0.7.3-streaming.3                                ...           5 years ago
  • 0.7.3-streaming.2                                ...           5 years ago
  • 0.7.3-streaming.1                                ...           5 years ago
  • 0.7.3-streaming.0                                ...           5 years ago
  • 0.7.3-handle-secrets.2                                ...           5 years ago
  • 0.7.3-handle-secrets.1                                ...           5 years ago
  • 0.7.3-handle-secrets.0                                ...           5 years ago
  • 0.7.2                                ...           5 years ago
  • 0.7.1                                ...           5 years ago
  • 0.7.0                                ...           5 years ago
  • 0.6.0                                ...           5 years ago
  • 0.5.0                                ...           5 years ago
  • 0.4.1                                ...           5 years ago
  • 0.3.1                                ...           5 years ago
  • 0.3.0                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (6)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |