3. Create a key value store by running the following command an put it in the `wrangler.toml` as `<Key Value Store ID>`.
```
npx wrangler kv:namespace create media-server
```
![image](docs/01-kv.png)
4. Create an R2 bucket by running the following command an put it in the `wrangler.toml` as `<R2 bucket name>`.
```
npx wrangler r2 bucket create media-server
```
5. Make sure you have chosen a worker name in Chnage "<nameoftheworker>" in your `wrangler.toml` and then deploy the Worker by running:
```bash
npm install
npm run deploy
```
![image](docs/02-worker-overview.png)
6. Now you can go into the worker settings and add a custom domain:
![image](docs/03-custom-domain.png)
7. Finally you need to enter this new custom domain in the `wrangler.toml` for the `PUBLIC_URL` variable. Also make sure you set `ALLOWED_NPUBS` to either `""` for public access or enter your `npub` to limit access.
8. Run `deploy` again to apply the last variable changes.
```bash
npm run deploy
```
## Build
The worker can be run locally by using the following commands: