taskvalve/functions

1.0.1 2023-10-18 17:52 UTC

This package is auto-updated.

Last update: 2024-12-18 21:13:24 UTC


README

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