Run TypeScript functions in the cloud from your Laravel PHP workflows!
composer require taskvalve/functions
config/services.php
'taskvalve' => [
'api_key' => env('TASKVALVE_API_KEY'),
],
.env
TASKVALVE_API_KEY=[YOUR_API KEY}
use TaskValve\CloudFunction;
use Workflow\ActivityStub;
use Workflow\Workflow;
use Workflow\WorkflowStub;
class MyWorkflow extends Workflow
{
public function execute()
{
return yield ActivityStub::make(CloudFunction::class, 'my-function');
}
}
See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API for Request
and Response
documentation.
export default async (request) => {
return new Response(JSON.stringify({ data: ['test'] }), {
headers: { 'content-type': 'application/json' }
})
}