File
Blob: samples/async-context/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 | # Every configuration defines the one or more sockets on which the server will listene. |
| 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 | modules = [ |
| 31 | (name = "worker", esModule = embed "worker.js") |
| 32 | ], |
| 33 | compatibilityDate = "2023-02-28", |
| 34 | # Only ask for workerd's implementation of `node:async_hooks`'s AsyncLocalStorage, |
| 35 | # instead of all of the node compatibility APIs, provided by `nodejs_compat`. See: |
| 36 | # https://developers.cloudflare.com/workers/configuration/compatibility-dates/#nodejs-compatibility-flag |
| 37 | compatibilityFlags = ["nodejs_als"] |
| 38 | ); |