functionly-examples/todoDBAdvanced at master · jaystack/functionly-examples · GitHub
Skip to content

Latest commit

 

History

History

Folders and files

README.md

todoDBAdvanced

first steppes based on todoDb

class extensions

onHandle

export class GetAllTodos extends TodoService {

    ...

    // onHandle_${environment}
    // onHandle_aws
    // onHandle_local

    public static async onHandle_aws(event, context, cb): Promise<any> {
        console.log('Hello onHandle_aws')
    }

    public static async onHandle_local(req, res, next): Promise<any> {
        console.log('Hello onHandle_local')
    }
}

return any value if you want handle the result

export class GetAllTodos extends TodoService {
    ...
    public static async onHandle_local(req, res, next): Promise<any> {
        console.log('Hello onHandle_local')
        res.json({ ok1: 2 })
        return true
    }
}

handle function will not invoked in local environment

onInvoke

export class PersistTodo extends TodoService {
    ...
    public static async onInvoke({ params, invokeConfig }): Promise<void> {
        console.log('onInvoke', params, invokeConfig)
    }


    // onInvoke_${environment}
    // onInvoke_aws
    // onInvoke_local

    // available parameters:
    // invokeParams, params, invokeConfig, parameterMapping, currentEnvironment, environmentMode 
    public static async onInvoke_aws({ params }): Promise<void> {
        console.log('onInvoke_aws', params)
    }
}

onInject

export class TodoTable extends DynamoTable {

    public async onInject({ parameter }): Promise<void> {
        console.log('onInject', parameter)
    }

    public static async onInject({ parameter }): Promise<any> {
        console.log('onInject static', parameter)
    }
}

the static onInject method can return a value which will be injected, but then the instance level onInject will not be called