FaasJS
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文
Home
  • Guide
  • Documents
  • Starter Template
  • Changelog
  • Ecosystem

    • VS Code Plugin
    • Docker Images
  • Github
  • Contributing
  • Sponsor
  • Security
  • English
  • 简体中文

Documents / @faasjs/types / InferFaasAction

Type Alias: InferFaasAction<TFunc>

InferFaasAction<TFunc> = object

Infer the FaasAction type from a Func.

Example

import { useFunc } from '@faasjs/func'
import { useHttp } from '@faasjs/http'
import type { InferFaasAction } from '@faasjs/types'

export const func = useFunc<
  {
    params: { // define the params type
      number: number
    }
  },
  unknown, // context type, can be skipped
  number // define the return type
>(() => {
  useHttp()

  return ({ event}) => {
    return event.params.number + 1
  }
})

// declare the action type to FaasActions
declare module '@faasjs/types' {
  interface FaasActions {
    // if 'demo' is the action path
    'demo': InferFaasAction<typeof func>
  }
}

Type Parameters

TFunc

TFunc extends Func

Properties

Data

Data: Awaited<ReturnType<ReturnType<TFunc["export"]>["handler"]>>

Params

Params: Parameters<ReturnType<TFunc["export"]>["handler"]>[0]["params"]