console/packages/services/cdn-worker
2023-01-30 18:32:07 +01:00
..
src Extra read from KV storage (#1185) 2023-01-30 18:32:07 +01:00
tests Extra read from KV storage (#1185) 2023-01-30 18:32:07 +01: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 Drop build-local scripts, build Workers for all targets, adjust turbo cache (#1105) 2023-01-23 17:44:53 +02:00
package.json feat: support new cdn tokens (#1061) 2023-01-27 12:59:09 +01:00
README.md Update dependency @theguild/prettier-config to v1 (#676) 2022-11-24 10:00:41 +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 ephermal 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.