console/packages/services/cdn-worker
Kamil Kisiela 36413f1682
Use ETag and If-None-Match in CDN and clients (#427)
* Use ETag and If-None-Match in CDN and clients

* Document it in 'Using registry' chapter
2022-09-30 13:37:57 +02:00
..
src Use ETag and If-None-Match in CDN and clients (#427) 2022-09-30 13:37:57 +02:00
tests Use ETag and If-None-Match in CDN and clients (#427) 2022-09-30 13:37:57 +02: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 Hello 2022-05-18 09:26:57 +02:00
package.json Fix missing dependencies between packages (#121) 2022-05-27 14:15:11 +02:00
README.md enable and fixes errors for @typescript-eslint/no-floating-promises rule (#150) 2022-06-23 12:04:10 +02:00
tsconfig.json $ prettier <all> (#46) 2022-05-24 16:31:53 +03: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: yarn 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.