console/packages/services/cdn-worker
renovate[bot] 0aa599d722
chore(deps): update dependency undici to v6.20.1 (#5809)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-10-28 11:23:52 +02:00
..
src Use AbortSignal.any (#5565) 2024-10-05 11:07:41 +03:00
tests Read response body closer to the fetch call (#5562) 2024-08-29 19:11:06 +02:00
.env.template No redirects in CDN Worker (#5540) 2024-08-28 05:23:07 +00:00
.gitignore $ prettier <all> (#46) 2022-05-24 16:31:53 +03:00
.npmignore Hello 2022-05-18 09:26:57 +02:00
build.mjs Node v22 (#4980) 2024-06-21 12:42:02 +02:00
package.json chore(deps): update dependency undici to v6.20.1 (#5809) 2024-10-28 11:23:52 +02:00
README.md Optional s3_session_token variable and remove setting region to auto (#2674) 2023-07-27 11:34:29 +00:00
tsconfig.json TS skipLibCheck everywhere, starting from root tsconfig (#588) 2022-11-03 15:00:58 +00:00

Hive CDN Worker

Hive comes with a CDN worker (deployed to CF Workers), along with KV cache to storage.

Standalone Development

To run Hive CDN locally, you can use the following command: pnpm dev.

Note: during dev, KV is mocked using JS Map, so it's ephemeral and will be deleted with any change in code.

To publish manually a schema, for target id 1:

curl -X PUT http://localhost:4010/1/storage/kv/namespaces/2/values/target:1:schema --data-raw '{"sdl": "type Query { foo: String }" }' -H 'content-type: text/plain'

You can also use the following to dump everything stored in the mocked KV:

curl http://localhost:4010/dump

To fetch a specific resource, for target id 1, run one of the following:

curl http://localhost:4010/1/schema -H "x-hive-cdn-key: fake"
curl http://localhost:4010/1/sdl -H "x-hive-cdn-key: fake"
curl http://localhost:4010/1/introspection -H "x-hive-cdn-key: fake"

Hive CDN Auth and access management is not enforced AT ALL during development.

Local Development with Hive Server

Hive server has CF_BASE_PATH env var that tells is where to send the published schemas.

To connect your server to the local, mocked CDN, make sure you have the following in packages/server/.env:

CF_BASE_PATH=http://localhost:4010

This way, your local Hive instance will be able to send schema to the locally running CDN Worker.