To run a local instance, you will need to install [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/).
It might take a few minutes to build the image and start the container, running at port 4173.
### Nix Flake
You can use [nix](https://nixos.org/) to set up a development environment, we have a [flake](https://nixos.wiki/wiki/Flakes) that setups `nodejs` and `pnpm`.
1. Fork the repository and clone it to your local machine with `git clone https://github.com/fmhy/edit.git`.
2. Run `nix flake update` to update the flake lock file.
3. Run `nix develop` to enter the development environment.
4. Make your changes.
5. Exit the development environment by running `exit`.
Update `wrangler.toml` with your Cloudflare account information:
1. Get your account ID from the Cloudflare dashboard (found in the right sidebar)
2. Replace the `account_id` value in `wrangler.toml` with your account ID
3. If you're using a custom domain, keep `workers_dev = false` and update the `routes` section
4. If you're deploying to `*.workers.dev`, set `workers_dev = true` and remove the `routes` section
#### Step 2: Create KV Namespace
Create a KV namespace for data storage:
```bash
npx wrangler kv:namespace create STORAGE
```
This command will return a namespace ID. Copy this ID and replace the `id` value in the `[[kv_namespaces]]` section of `wrangler.toml` (line 14).
**Note:** If you want to deploy without running Wrangler locally (e.g., in CI/CD), you'll need to:
1. Create the KV namespace manually in the Cloudflare dashboard
2. Update both the `account_id` and `id` values in `wrangler.toml` in your fork
#### Step 3: Build and Deploy
Build and deploy the API:
```bash
# Build the API
pnpm api:build
# Deploy to Cloudflare Workers
pnpm api:deploy
```
The API will be deployed to your configured domain or `*.workers.dev` subdomain.
#### Rate Limiting (Optional)
The rate limiter binding requires setup through the Cloudflare dashboard. You can skip this for basic deployments or configure it later through the Workers dashboard under the "Rate limiting" section.
You should be able to use any reverse proxy with this vitepress website, but find a reasonable config for an nginx server [in the repo here](https://github.com/fmhy/edit/blob/main/.github/assets/nginx.conf)