Nuclear Pumpkin Mocha

    @netlify/functions
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.0 • Public • Published

    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!

    Keywords

    none

    Install

    npm i @netlify/functions

    DownloadsWeekly Downloads

    175,652

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    36.7 kB

    Total Files

    29

    Last publish

    Collaborators

    • danez
    • jackiewmacharia
    • sarahetter
    • kevsamoei
    • orinokai
    • ericap
    • seanroberts
    • dustincrogers
    • skn0tt
    • mikewen
    • dengeist
    • biilmann
    • marcus.netlify
    • jgantunes
    • eduardoboucas
    • netlify-bot
    • nasiba
    • zachleat
    • ascorbic