File
Blob: samples/helloworld/config.capnp
| 1 | # Imports the base schema for workerd configuration files. |
| 2 | |
| 3 | # Refer to the comments in /src/workerd/server/workerd.capnp for more details. |
| 4 | |
| 5 | using Workerd = import "/workerd/workerd.capnp"; |
| 6 | |
| 7 | # A constant of type Workerd.Config defines the top-level configuration for an |
| 8 | # instance of the workerd runtime. A single config file can contain multiple |
| 9 | # Workerd.Config definitions and must have at least one. |
| 10 | const helloWorldExample :Workerd.Config = ( |
| 11 | |
| 12 | # Every workerd instance consists of a set of named services. A worker, for instance, |
| 13 | # is a type of service. Other types of services can include external servers, the |
| 14 | # ability to talk to a network, or accessing a disk directory. Here we create a single |
| 15 | # worker service. The configuration details for the worker are defined below. |
| 16 | services = [ (name = "main", worker = .helloWorld) ], |
| 17 | |
| 18 | # Each configuration defines the sockets on which the server will listen. |
| 19 | # Here, we create a single socket that will listen on localhost port 8080, and will |
| 20 | # dispatch to the "main" service that we defined above. |
| 21 | sockets = [ ( name = "http", address = "*:8080", http = (), service = "main" ) ] |
| 22 | ); |
| 23 | |
| 24 | # The definition of the actual helloWorld worker exposed using the "main" service. |
| 25 | # In this example the worker is implemented as a single simple script (see worker.js). |
| 26 | # The compatibilityDate is required. For more details on compatibility dates see: |
| 27 | # https://developers.cloudflare.com/workers/platform/compatibility-dates/ |
| 28 | |
| 29 | const helloWorld :Workerd.Worker = ( |
| 30 | serviceWorkerScript = embed "worker.js", |
| 31 | compatibilityDate = "2023-02-28", |
| 32 | ); |