Skip to content
This repository has been archived by the owner on Feb 27, 2022. It is now read-only.

Wrangler template for a Cloudflare Workers + Haskell (Asterius) project

License

Notifications You must be signed in to change notification settings

ento/worker-haskell-template

Repository files navigation

worker-haskell-template

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

  • src/worker.mjs is the 'entry' module that defines the fetch event listener and loads the Asterius runtime.
  • src/worker.hs implements the actual request handling code in Haskell.
  • webpack.config.js holds the webpack config that integrates the Asterius build process nicely with Wrangler.

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.

About

Wrangler template for a Cloudflare Workers + Haskell (Asterius) project

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published