<config lang="json">
{
    "name": "JavaScript Web Worker App",
    "type": "web-worker",
    "tags": ["javascript", "modern"],
    "ui": "",
    "version": "0.1.0",
    "cover": "",
    "description": "A web worker app that can be used to run JavaScript code in the background.",
    "icon": "⚡",
    "api_version": "0.1.8",
    "requirements": [],
    "dependencies": [],
    "startup_config": {
        "timeout": 60,
        "wait_for_service": "default",
        "stop_after_inactive": 600
    }
}
</config>

<script lang="javascript">
class HyphaApp {
    async setup() {
        await api.log('initialized')
        await api.registerService({
            "id": "echo",
            "name": "echo",
            "type": "echo",
            "config": {
                "visibility": "public"
            },
            echo(data){
                return data
            }
        }, true)
    }

    async add2(a){
        return a + 2
    }

    async run(ctx) {
        await api.alert('hello world.')
    }
}

api.export(new HyphaApp())
</script> 