{"id":15760048,"url":"https://github.com/imskr/cloudflare-fullstack","last_synced_at":"2025-06-13T06:36:42.800Z","repository":{"id":106945694,"uuid":"255643550","full_name":"imskr/cloudflare-fullstack","owner":"imskr","description":"Cloudflare Workers: Full Stack","archived":false,"fork":false,"pushed_at":"2020-04-15T07:00:11.000Z","size":13,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T09:14:30.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/imskr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE_APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-14T15:11:26.000Z","updated_at":"2025-01-04T13:47:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"5f2d51bc-0ed8-4c2c-9262-aea61c44cfde","html_url":"https://github.com/imskr/cloudflare-fullstack","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/imskr/cloudflare-fullstack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imskr%2Fcloudflare-fullstack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imskr%2Fcloudflare-fullstack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imskr%2Fcloudflare-fullstack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imskr%2Fcloudflare-fullstack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imskr","download_url":"https://codeload.github.com/imskr/cloudflare-fullstack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imskr%2Fcloudflare-fullstack/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259595519,"owners_count":22881854,"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-10-04T10:40:43.292Z","updated_at":"2025-06-13T06:36:42.781Z","avatar_url":"https://github.com/imskr.png","language":"JavaScript","readme":"# Cloudflare Workers Internship Application: Full-Stack\n\n## What is it?\n\nUsing Cloudflare Workers, you'll deploy an application that will randomly send users to one of two webpages. This project will teach you how to write applications with the Cloudflare Workers API, manage and develop them using the command-line tool Wrangler, and deploy them to the free workers.dev deployment playground.\n\n## Useful Links\n\n- [Workers Quick Start documentation](https://developers.cloudflare.com/workers/quickstart/)\n- [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)\n- [HTMLRewriter](https://developers.cloudflare.com/workers/reference/apis/html-rewriter/)\n- [Cookie documentation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies)\n\n## Get Started\n\n### 1. Install the workers command-line tool wrangler.\n\nThe Workers Quick Start in the documentation shows how to get started with Wrangler, creating a project, and configuring and deploying it. We highly recommend that you spend time reading and following along with this guide!\n\nTo begin, install the [Wrangler](https://github.com/cloudflare/wrangler) command-line tool.\n\n### 2. Generate a new project using `wrangler generate` command\n\nUsing the `generate` command (covered in the Quick Start), generate a new project with a name of your choice:\n\n```sh\n$ wrangler generate your-project-name https://github.com/cloudflare-internship-2020/internship-application-fullstack\n```\n\n### 3. Use `wrangler dev` to locally test/develop your application\n\nThe recently launched [`wrangler dev`](https://github.com/cloudflare/wrangler#-dev) feature will allow you to begin developing your application using `localhost` - this means that you can test your project locally and make sure it works, without having to sort out deployment until later in the exercise.\n\nNote that a major benefit of using `wrangler dev` is the ability to output `console.log` statements to your terminal - this is super useful for inspecting HTTP responses and variables!\n\n## Requirements\n\n### 1. Request the URLs from the API\n\nMake a fetch request inside of your script's event handler to the URL `https://cfw-takehome.developers.workers.dev/api/variants`, and parse the response as JSON. The response will be an array of URLs, which should be saved to a variable.\n\n### 2. Request a (random: see #3) variant\n\nMake a fetch request to one of the two URLs, and return it as the response from the script.\n\n### 3. Distribute requests between variants\n\nThe `/api/variants` API route will return an array of two URLs. Requests should be evenly distributed between the two urls, in A/B testing style. This means that when a client makes a request to the Workers script, the script should roughly return each variant around 50% of the time.\n\n## Deployment\n\n### 1. Register a workers.dev subdomain\n\nEvery Workers user has access to a free, unique workers.dev subdomain, which allows you to deploy your projects to a stable URL without needing to purchase domains and configure DNS records. Following the Quick Start linked above includes setting up a workers.dev subdomain!\n\n### 2. A user should be able to visit the deployed version of the site\n\nUsing wrangler's `publish` command, you can deploy your application and make it available under your workers.dev subdomain. Make sure to include this when you submit your project!\n\n## Submitting your project\n\nWhen submitting your project, you should prepare your code for upload to Greenhouse. The preferred method for doing this is to create a \"ZIP archive\" of your project folder: for more instructions on how to do this on Windows and Mac, see [this guide](https://www.sweetwater.com/sweetcare/articles/how-to-zip-and-unzip-files/).\n\nIn addition to submitting your project code, you should also submit the URL of your deployed project (see \"Deployment\"). This will be in the format `your-project-name.your-subdomain.workers.dev`.\n\n## Extra Credit\n\n### 1. Changing copy/URLs\n\nFor each variant page, there are a number of items on the page that can be customized. Try changing the following values inside of the variant, adding your own text or URLs:\n\n- `title`: the title of the web page, displayed on the window or tab title in your browser.\n- `h1#title`: the main title of the page. By default, this displays \"Variant 1\" or \"Variant 2\"\n- `p#description`: the description paragraph on the page. By default, this displays the text \"This is variant X of the take home project!\".\n- `a#url`: a Call to Action link with strong emphasis on the page. Try changing this to a URL of your choice, such as your personal website, and make sure to update the text \"Return to cloudflare.com\" as well!\n\nThis can be done using the [HTMLRewriter](https://developers.cloudflare.com/workers/reference/apis/html-rewriter/) API built into the Workers runtime, or using simple text replacement.\n\n### 2. Persisting variants\n\nIf a user visits the site and receives one of the two URLs, persist which URL is chosen in a cookie so that they always see the same variant when they return to the application. A cookie would be a great way to implement this!\n\n### 3. Publish to a domain\n\nIf you have a registered domain/zone with Cloudflare, try deploying your project by customizing the `zone_id` and `route` in your `wrangler.toml`. Make sure to check out the [Quick Start](https://developers.cloudflare.com/workers/quickstart) in the Workers docs for details on how to do this! **Note:** domains cost money, so if you don't have one, please don't feel obligated to buy one for this exercise. This is an extra credit task and you won't be penalized for skipping this one, we promise!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimskr%2Fcloudflare-fullstack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimskr%2Fcloudflare-fullstack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimskr%2Fcloudflare-fullstack/lists"}