{"id":19542589,"url":"https://github.com/fable-compiler/cfworker-hello-world","last_synced_at":"2025-04-26T17:31:19.510Z","repository":{"id":47617375,"uuid":"305570167","full_name":"fable-compiler/cfworker-hello-world","owner":"fable-compiler","description":"Cloudflare worker","archived":false,"fork":false,"pushed_at":"2022-09-16T18:22:23.000Z","size":188,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-04-04T16:42:00.657Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"F#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fable-compiler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-20T02:39:53.000Z","updated_at":"2023-08-06T07:48:38.000Z","dependencies_parsed_at":"2023-01-18T11:00:41.476Z","dependency_job_id":null,"html_url":"https://github.com/fable-compiler/cfworker-hello-world","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2Fcfworker-hello-world","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2Fcfworker-hello-world/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2Fcfworker-hello-world/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fable-compiler%2Fcfworker-hello-world/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fable-compiler","download_url":"https://codeload.github.com/fable-compiler/cfworker-hello-world/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251025762,"owners_count":21524860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T03:15:14.982Z","updated_at":"2025-04-26T17:31:19.240Z","avatar_url":"https://github.com/fable-compiler.png","language":"F#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FSharp/Fable 'Hello World' on Cloudflare Workers\n\nThis Repo shows how to run 'Hello World' in [FSharp](https://docs.microsoft.com/en-us/dotnet/fsharp/get-started/install-fsharp) on Cloudflare Workers via the [Fable](https://fable.io) JavaScript transpiler. Workers are a simple inexpensive way to execute functions on Cloudflare edge network. They can be used for anything from utilities to full-on WebAPI's. For a more detailed description of Workers in FSharp see:\n* [Description of a FSharp 'Hello World' Worker](https://github.com/jbeeko/cfworker-hello-world)\n* [Description of a FSharp WebAPI Worker](https://github.com/jbeeko/cfworker-web-api)\n\n## Setting Up Your Environment\n\n### Prerequisits\n* A Cloudflare account, either [paid or free](https://dash.cloudflare.com/sign-up/workers). Needed to provide the hosting environment to which your worker will be deployed.\n* [Wrangler](https://github.com/cloudflare/wrangler), the Cloudflare Workers CLI. This works with the webpack.config.js file to build and deploy your worker.\n* [.NET SDK](https://dotnet.microsoft.com), used to generate an F# abstract syntax tree from which the JavaScript is generated.\n* [Node.js](https://nodejs.org/en/), used to support the tooling to convert the AST to JavaScript.\n* An editor with F# support. [VisualStudio Code with Ionide is recomended](https://docs.microsoft.com/en-us/dotnet/fsharp/get-started/install-fsharp#install-f-with-visual-studio-code).\n\n### Install and Check Prerequisits\nPerform the following as some simple checks to ensure the pre-requisits are in place. At time of writing the following were working:\n* [Check](https://docs.microsoft.com/en-us/dotnet/fsharp/get-started/get-started-vscode) you are able to edit F# files.\n* [Log into Cloudflare](https://dash.cloudflare.com/login), you should be able to view the workers pannel.\n* `wrangler --version` -\u003e v1.10.3\n* `dotnet --version` -\u003e .NET Core 3.1 or .Net 5.0\n* `node -v` -\u003e v12.18\n\n### Configure Wrangler\nTo authenticate wrangler commands it is recomended you [configure wrangler](https://dash.cloudflare.com/sign-up/workers) with your APIKey using `wrangler config`.\n\n## Generating and Testing a Worker\n\n### Generate a New Project\nTo create a new project based on this template execute:\n```\nwrangler generate projectname https://github.com/fable-compiler/cfworker-hello-world\n```\n\n### Build and Deploy to Dev\n\n1. Run `dotnet tool restore`\n2. Run `dotnet fable watch src --outDir tmp --run wrangler dev`\nThis will run Fable and `wrangler dev` both in watch mode. Fable compiles F# to JavaScript. Wrangler then pushes the new javascript to your accounts Cloudflare Dev environment and starts a stub running locally for testing. Cloudflare has a blog [explaining](https://blog.cloudflare.com/announcing-wrangler-dev-the-edge-on-localhost/) how this works.\n\n### Test the Dev Worker:\n```\nMBPro:~ $ curl localhost:8787\nHello from Fable at: Mon Oct 19 2020 19:30:39 GMT+0000 (Coordinated Universal Time)\n```\n\n## Publish to Your Cloudflare Account\nTo publish your worker to your Cloudflare account first configure a [route and zone id](https://developers.cloudflare.com/workers/cli-wrangler/configuration) in your `./wrangler.toml` file. Then execute `wrangler publish` this will deploy the worker javascript file as specified in the TOML file.\n\n\u0026nbsp;\n\u003e **Note to Contributors:** PRs are welcome. Test changes by:\n\u003e\n\u003e * Creating a new project from the template: `wrangler generate my-proj file://\"path_to_local_repo`\"\n\u003e * Building and deploying the worker from root of generated my-proj: `dotnet fable watch src --outDir tmp --run wrangler dev`\n\u003e * Testing the worker: `$ curl localhost:8787`\n\u003e\n\u003e `Hello from Fable at: Sun Nov 08 2020 17:41:19 GMT+0000 (Coordinated Universal Time)`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffable-compiler%2Fcfworker-hello-world","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffable-compiler%2Fcfworker-hello-world","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffable-compiler%2Fcfworker-hello-world/lists"}