@faasjs/func
FaasJS's function module.
Install
npm install @faasjs/func
Modules
Classes
Type Aliases
- Config
- DeployData
- ExportedHandler
- FuncConfig
- Handler
- InvokeData
- LifeCycleKey
- MountData
- Next
- Plugin
- ProviderConfig
- UseifyPlugin
Functions
Type Aliases
Config
Ƭ Config: Object
Index signature
▪ [key: string
]: any
Type declaration
Name | Type |
---|---|
plugins? | { [key: string] : { [key: string] : any ; config? : { [key: string] : any ; } ; provider? : string | ProviderConfig ; type : string }; } |
providers? | { [key: string] : ProviderConfig ; } |
DeployData
Ƭ DeployData: Object
Index signature
▪ [key: string
]: any
Type declaration
Name | Type |
---|---|
config? | Config |
dependencies | { [name: string] : string ; } |
env? | string |
filename | string |
logger? | Logger |
name? | string |
plugins? | { [name: string] : { [key: string] : any ; config : { [key: string] : any ; } ; name? : string ; plugin : Plugin ; provider? : string ; type : string }; } |
root | string |
version? | string |
ExportedHandler
Ƭ ExportedHandler<TEvent
, TContext
, TResult
>: (event
: TEvent
, context?
: TContext
, callback?
: (...args
: any
) => any
) => Promise
<TResult
>
Type parameters
Name | Type |
---|---|
TEvent | any |
TContext | any |
TResult | any |
Type declaration
▸ (event
, context?
, callback?
): Promise
<TResult
>
Parameters
Name | Type |
---|---|
event | TEvent |
context? | TContext |
callback? | (...args : any ) => any |
Returns
Promise
<TResult
>
FuncConfig
Ƭ FuncConfig<TEvent
, TContext
, TResult
>: Object
Type parameters
Name | Type |
---|---|
TEvent | any |
TContext | any |
TResult | any |
Type declaration
Name | Type |
---|---|
handler? | Handler <TEvent , TContext , TResult > |
plugins? | Plugin [] |
Handler
Ƭ Handler<TEvent
, TContext
, TResult
>: (data
: InvokeData
<TEvent
, TContext
>) => Promise
<TResult
>
Type parameters
Name | Type |
---|---|
TEvent | any |
TContext | any |
TResult | any |
Type declaration
▸ (data
): Promise
<TResult
>
Parameters
Name | Type |
---|---|
data | InvokeData <TEvent , TContext > |
Returns
Promise
<TResult
>
InvokeData
Ƭ InvokeData<TEvent
, TContext
, TResult
>: Object
Type parameters
Name | Type |
---|---|
TEvent | any |
TContext | any |
TResult | any |
Index signature
▪ [key: string
]: any
Type declaration
Name | Type |
---|---|
callback | any |
config | Config |
context | TContext |
event | TEvent |
handler? | Handler <TEvent , TContext , TResult > |
logger | Logger |
response | any |
LifeCycleKey
Ƭ LifeCycleKey: "onDeploy"
| "onMount"
| "onInvoke"
MountData
Ƭ MountData: Object
Index signature
▪ [key: string
]: any
Type declaration
Name | Type |
---|---|
config | Config |
context | any |
event | any |
Next
Ƭ Next: () => Promise
<void
>
Type declaration
▸ (): Promise
<void
>
Returns
Promise
<void
>
Plugin
Ƭ Plugin: Object
Index signature
▪ [key: string
]: any
Type declaration
Name | Type |
---|---|
name | string |
onDeploy? | (data : DeployData , next : Next ) => void | Promise <void > |
onInvoke? | (data : InvokeData , next : Next ) => void | Promise <void > |
onMount? | (data : MountData , next : Next ) => void | Promise <void > |
type | string |
ProviderConfig
Ƭ ProviderConfig: Object
Type declaration
Name | Type |
---|---|
config | { [key: string] : any ; } |
type | string |
UseifyPlugin
Ƭ UseifyPlugin<T
>: T
& { mount?
: (data?
: { config?
: Config
}) => Promise
<T
> }
Type parameters
Name |
---|
T |
Functions
useFunc
▸ useFunc<TEvent
, TContext
, TResult
>(handler
): Func
<TEvent
, TContext
, TResult
>
// pure function
export default useFunc(() => {
return () => {
return 'Hello World'
}
})
// with http
import { useHttp } from '@faasjs/http'
export default useFunc(() => {
const http = useHttp<{ name: string }>()
return () => {
return `Hello ${http.params.name}`
}
})
Type parameters
Name | Type |
---|---|
TEvent | any |
TContext | any |
TResult | any |
Parameters
Name | Type |
---|---|
handler | () => Handler <TEvent , TContext , TResult > |
Returns
Func
<TEvent
, TContext
, TResult
>
usePlugin
▸ usePlugin<T
>(plugin
): UseifyPlugin
<T
>
Type parameters
Name | Type |
---|---|
T | extends Plugin |
Parameters
Name | Type |
---|---|
plugin | UseifyPlugin <T > |
Returns
UseifyPlugin
<T
>