0.2.6 • Published 1 year ago

@adaliszk/fission v0.2.6

Weekly downloads
-
License
BSD-3-Clause
Repository
github
Last release
1 year ago

Types for Node.js Fission Functions

Usage

  1. Install the package pnpm install -D @adaliszk/fission
  2. Annotate your function with types
  3. Build your typescript function into Node.js
  4. Create the function: fission function create --name hallo --code dist/hello.js --env nodejs

Types

  • FunctionHandler<T>: Combined type for any function handler export

    import { FunctionHandler } from '@adaliszk/fission'
    
    export const handler1: FunctionHandler<string> = (context) =>
    {
        return {
            status: 200,
            body: 'OK',
        }
    }
    
    export const handler2: FunctionHandler<string> = (context, callback) =>
    {
        callback(200, 'OK')
    }
    
    export const handler3: FunctionHandler = (socket, clients) =>
    {
        socket.on('message', (data) => {
            console.log('received: %s', data);
        })
    }
  • FunctionCallbackHandler<T>: Callback-style handler function

    import { FunctionCallbackHandler } from '@adaliszk/fission'
    
    export const handler: FunctionCallbackHandler<string> = (context, callback) =>
    {
        callback(200, 'OK')
    } 
  • FunctionResponseHandler<T>: Generic Request-Response handler

    import { FunctionResponseHandler } from '@adaliszk/fission'
    
    export const handler: FunctionResponseHandler<string> = (context) =>
    {
        return {
            status: 200,
            body: 'OK',
        }
    } 
  • FunctionSocketHandler<T>: Websocket function

    import { FunctionSocketHandler } from '@adaliszk/fission'
    
    export const handler: FunctionSocketHandler = (socket, clients) =>
    {
        socket.on('message', (data) => {
            console.log('received: %s', data);
        })
    } 
0.2.6

1 year ago

0.2.3

1 year ago

0.2.4

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago