···11+/**
22+ * Welcome to Cloudflare Workers! This is your first worker.
33+ *
44+ * - Run `npm run dev` in your terminal to start a development server
55+ * - Open a browser tab at http://localhost:8787/ to see your worker in action
66+ * - Run `npm run deploy` to publish your worker
77+ *
88+ * Bind resources to your worker in `wrangler.toml`. After adding bindings, a type definition for the
99+ * `Env` object can be regenerated with `npm run cf-typegen`.
1010+ *
1111+ * Learn more at https://developers.cloudflare.com/workers/
1212+ */
1313+1414+export default {
1515+ async fetch(request, env, ctx): Promise<Response> {
1616+ return new Response('Hello World!');
1717+ },
1818+} satisfies ExportedHandler<Env>;
+25
test/index.spec.ts
···11+// test/index.spec.ts
22+import { env, createExecutionContext, waitOnExecutionContext, SELF } from 'cloudflare:test';
33+import { describe, it, expect } from 'vitest';
44+import worker from '../src/index';
55+66+// For now, you'll need to do something like this to get a correctly-typed
77+// `Request` to pass to `worker.fetch()`.
88+const IncomingRequest = Request<unknown, IncomingRequestCfProperties>;
99+1010+describe('Hello World worker', () => {
1111+ it('responds with Hello World! (unit style)', async () => {
1212+ const request = new IncomingRequest('http://example.com');
1313+ // Create an empty context to pass to `worker.fetch()`.
1414+ const ctx = createExecutionContext();
1515+ const response = await worker.fetch(request, env, ctx);
1616+ // Wait for all `Promise`s passed to `ctx.waitUntil()` to settle before running test assertions
1717+ await waitOnExecutionContext(ctx);
1818+ expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
1919+ });
2020+2121+ it('responds with Hello World! (integration style)', async () => {
2222+ const response = await SELF.fetch('https://example.com');
2323+ expect(await response.text()).toMatchInlineSnapshot(`"Hello World!"`);
2424+ });
2525+});
···11+{
22+ "compilerOptions": {
33+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
44+55+ /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
66+ "target": "es2021",
77+ /* Specify a set of bundled library declaration files that describe the target runtime environment. */
88+ "lib": ["es2021"],
99+ /* Specify what JSX code is generated. */
1010+ "jsx": "react-jsx",
1111+1212+ /* Specify what module code is generated. */
1313+ "module": "es2022",
1414+ /* Specify how TypeScript looks up a file from a given module specifier. */
1515+ "moduleResolution": "Bundler",
1616+ /* Specify type package names to be included without being referenced in a source file. */
1717+ "types": [
1818+ "@cloudflare/workers-types/2023-07-01"
1919+ ],
2020+ /* Enable importing .json files */
2121+ "resolveJsonModule": true,
2222+2323+ /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
2424+ "allowJs": true,
2525+ /* Enable error reporting in type-checked JavaScript files. */
2626+ "checkJs": false,
2727+2828+ /* Disable emitting files from a compilation. */
2929+ "noEmit": true,
3030+3131+ /* Ensure that each file can be safely transpiled without relying on other imports. */
3232+ "isolatedModules": true,
3333+ /* Allow 'import x from y' when a module doesn't have a default export. */
3434+ "allowSyntheticDefaultImports": true,
3535+ /* Ensure that casing is correct in imports. */
3636+ "forceConsistentCasingInFileNames": true,
3737+3838+ /* Enable all strict type-checking options. */
3939+ "strict": true,
4040+4141+ /* Skip type checking all .d.ts files. */
4242+ "skipLibCheck": true
4343+ },
4444+ "exclude": ["test"],
4545+ "include": ["worker-configuration.d.ts", "src/**/*.ts"]
4646+}
···11+// Generated by Wrangler
22+// After adding bindings to `wrangler.toml`, regenerate this interface via `npm run cf-typegen`
33+interface Env {
44+}
+114
wrangler.toml
···11+#:schema node_modules/wrangler/config-schema.json
22+name = "bsky-labeler"
33+main = "src/index.ts"
44+compatibility_date = "2024-12-18"
55+compatibility_flags = ["nodejs_compat"]
66+77+# Workers Logs
88+# Docs: https://developers.cloudflare.com/workers/observability/logs/workers-logs/
99+# Configuration: https://developers.cloudflare.com/workers/observability/logs/workers-logs/#enable-workers-logs
1010+[observability]
1111+enabled = true
1212+1313+# Automatically place your workloads in an optimal location to minimize latency.
1414+# If you are running back-end logic in a Worker, running it closer to your back-end infrastructure
1515+# rather than the end user may result in better performance.
1616+# Docs: https://developers.cloudflare.com/workers/configuration/smart-placement/#smart-placement
1717+# [placement]
1818+# mode = "smart"
1919+2020+# Variable bindings. These are arbitrary, plaintext strings (similar to environment variables)
2121+# Docs:
2222+# - https://developers.cloudflare.com/workers/wrangler/configuration/#environment-variables
2323+# Note: Use secrets to store sensitive data.
2424+# - https://developers.cloudflare.com/workers/configuration/secrets/
2525+# [vars]
2626+# MY_VARIABLE = "production_value"
2727+2828+# Bind the Workers AI model catalog. Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network
2929+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#workers-ai
3030+# [ai]
3131+# binding = "AI"
3232+3333+# Bind an Analytics Engine dataset. Use Analytics Engine to write analytics within your Pages Function.
3434+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#analytics-engine-datasets
3535+# [[analytics_engine_datasets]]
3636+# binding = "MY_DATASET"
3737+3838+# Bind a headless browser instance running on Cloudflare's global network.
3939+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#browser-rendering
4040+# [browser]
4141+# binding = "MY_BROWSER"
4242+4343+# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
4444+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
4545+# [[d1_databases]]
4646+# binding = "MY_DB"
4747+# database_name = "my-database"
4848+# database_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
4949+5050+# Bind a dispatch namespace. Use Workers for Platforms to deploy serverless functions programmatically on behalf of your customers.
5151+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#dispatch-namespace-bindings-workers-for-platforms
5252+# [[dispatch_namespaces]]
5353+# binding = "MY_DISPATCHER"
5454+# namespace = "my-namespace"
5555+5656+# Bind a Durable Object. Durable objects are a scale-to-zero compute primitive based on the actor model.
5757+# Durable Objects can live for as long as needed. Use these when you need a long-running "server", such as in realtime apps.
5858+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#durable-objects
5959+# [[durable_objects.bindings]]
6060+# name = "MY_DURABLE_OBJECT"
6161+# class_name = "MyDurableObject"
6262+6363+# Durable Object migrations.
6464+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#migrations
6565+# [[migrations]]
6666+# tag = "v1"
6767+# new_classes = ["MyDurableObject"]
6868+6969+# Bind a Hyperdrive configuration. Use to accelerate access to your existing databases from Cloudflare Workers.
7070+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#hyperdrive
7171+# [[hyperdrive]]
7272+# binding = "MY_HYPERDRIVE"
7373+# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
7474+7575+# Bind a KV Namespace. Use KV as persistent storage for small key-value pairs.
7676+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#kv-namespaces
7777+# [[kv_namespaces]]
7878+# binding = "MY_KV_NAMESPACE"
7979+# id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
8080+8181+# Bind an mTLS certificate. Use to present a client certificate when communicating with another service.
8282+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#mtls-certificates
8383+# [[mtls_certificates]]
8484+# binding = "MY_CERTIFICATE"
8585+# certificate_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
8686+8787+# Bind a Queue producer. Use this binding to schedule an arbitrary task that may be processed later by a Queue consumer.
8888+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
8989+# [[queues.producers]]
9090+# binding = "MY_QUEUE"
9191+# queue = "my-queue"
9292+9393+# Bind a Queue consumer. Queue Consumers can retrieve tasks scheduled by Producers to act on them.
9494+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#queues
9595+# [[queues.consumers]]
9696+# queue = "my-queue"
9797+9898+# Bind an R2 Bucket. Use R2 to store arbitrarily large blobs of data, such as files.
9999+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#r2-buckets
100100+# [[r2_buckets]]
101101+# binding = "MY_BUCKET"
102102+# bucket_name = "my-bucket"
103103+104104+# Bind another Worker service. Use this binding to call another Worker without network overhead.
105105+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#service-bindings
106106+# [[services]]
107107+# binding = "MY_SERVICE"
108108+# service = "my-service"
109109+110110+# Bind a Vectorize index. Use to store and query vector embeddings for semantic search, classification and other vector search use-cases.
111111+# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#vectorize-indexes
112112+# [[vectorize]]
113113+# binding = "MY_INDEX"
114114+# index_name = "my-index"