Create the Hello World code bundle

Your Hello World code bundle must contain the main.js and bundle.json files. See code bundle format for more information.

  1. Create a folder on your computer for the code bundle files.

  2. Go to the EdgeWorkers GitHub repository and download the main.js and bundle.json files from the helloworld project or create them using the values below.

  3. Use the Hello World code sample to create the JavaScript source in a file called main.js.

👍

When you start creating your own EdgeWorkers functions you can use the built-in Code bundle editor to validate and edit your bundle.json and main.js files.

// Hello World Example

export function onClientRequest(request) {
  request.respondWith(
      200, {},
      '<html><body><h1>Hello World From Akamai EdgeWorkers</h1></body></html>');
}

export function onClientResponse(request, response) {
  response.setHeader('X-Hello-World', 'From Akamai EdgeWorkers');
}

📘

Each time you want to activate a new EdgeWorkers code bundle or update an existing EdgeWorkers code bundle you need to create a new version number.

  1. Compress the files into a code bundle.
tar -czvf filename.tgz main.js bundle.json
  1. Next, follow these instructions to deploy the Hello World code bundle.