Skip to content

taskvalve/functions

Repository files navigation

TaskValve Functions

Run TypeScript functions in the cloud from your Laravel PHP workflows!

Installation

composer require taskvalve/functions

Configuration

config/services.php

'taskvalve' => [
    'api_key' => env('TASKVALVE_API_KEY'),
],

.env

TASKVALVE_API_KEY=[YOUR_API KEY}

Usage

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');
    }
}

Examples

See https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API for Request and Response documentation.

Return JSON

export default async (request) => {
    return new Response(JSON.stringify({ data: ['test'] }), { 
        headers: { 'content-type': 'application/json' }
    })
}