Home

Awesome

worker-haskell-template

A wrangler template for a Cloudflare Workers project with Asterius, a Haskell to WebAssembly compiler.

As Asterius is in the alpha development stage, this template may become outdated at any time.

Prerequisites

Usage

  1. Generate a project with wrangler if you have it installed in your system:

    wrangler generate myworker https://github.com/ento/worker-haskell-template
    

    If not, either clone this repo or download its archive from GitHub and unarchive locally.

  2. Install dependencies:

    cd myworker
    npm install
    
  3. Edit wrangler.toml and replace the account_id value with your Cloudflare account ID.

    If you didn't use wrangler to generate the project, replace the name value as well.

    For more information, including how to deploy to your Cloudflare Zone, see Cloudflare's documentation.

  4. Build and test:

    npm run build
    npm run test
    
  5. Preview with:

    npx wrangler preview
    

    You should see "Hello from Haskell" in response to GET requests. Send a POST request with a body like {"name": "world"} to get "Hello world" in return.

  6. Publish:

    npx wrangler publish
    

This template is licensed under the terms of the 0BSD license.