docs: simplify the GoTo READMEs #48
No files matched your search
@@ -1,95 +1,59 @@
|
||||
Goto is a small, YAML-first, self-hosted URL shortener.
|
||||
# GoTo
|
||||
|
||||
The current runtime provides `GET /healthz` and `HEAD /healthz`. Other paths return 404. Redirect configuration and administration are not available yet.
|
||||
A small, self-hosted URL shortener. Give a long address a short name and get on with it.
|
||||
|
||||
One YAML file can run links for several domains. The admin shows what’s configured and how often links are used. To change a link, edit the file.
|
||||
|
||||
## Get started
|
||||
|
||||
Let’s assume you have Docker Compose. From a checkout:
|
||||
|
||||
```sh
|
||||
mkdir -p apps/web/config apps/web/data
|
||||
```
|
||||
|
||||
Save this as `apps/web/config/goto.yaml`. Pick a password before starting.
|
||||
|
||||
```yaml
|
||||
url:
|
||||
app: http://localhost:5173
|
||||
|
||||
auth:
|
||||
credentials:
|
||||
username: admin
|
||||
password: 'pick-a-local-password'
|
||||
|
||||
domains:
|
||||
localhost:5173:
|
||||
links:
|
||||
/hello:
|
||||
url: https://example.org
|
||||
```
|
||||
|
||||
If your user and group IDs aren’t `1000:1000`, set `LOCAL_UID` and `LOCAL_GID` before running Compose.
|
||||
|
||||
```sh
|
||||
docker compose -f apps/web/docker-compose.dev.yml up --build --wait
|
||||
```
|
||||
|
||||
When the command finishes, open <http://localhost:5173/hello>. It should send you on your way. Sign in at <http://localhost:5173/admin> to see the link. The worker prepares Analytics in the background, so don’t stare at the chart waiting for that first click.
|
||||
|
||||
## Why this way?
|
||||
|
||||
**Why YAML?** You can review a diff and undo a bad edit. Keep the link rules in Git if you like; keep the passwords out of it. The admin is read-only so there’s no second place to change a link.
|
||||
|
||||
**Why a worker?** Sending someone to a link shouldn’t wait for a report. The web app redirects; the worker prepares reports from SQLite in the background.
|
||||
|
||||
**What gets kept?** Analytics keeps 90 days of detail by default. Set `analytics.retention_months: 0` to turn off detailed Analytics without losing lifetime totals. Stop both services before reducing retention or switching between zero and a positive value, then start them again.
|
||||
|
||||
## Configuration and deployment
|
||||
|
||||
The [example YAML](examples/goto.yaml) shows multiple domains, SSO, tags and conditional redirects. The [schema](packages/config/src/config.schema.json) has the full list of options. Most link edits take effect without a restart.
|
||||
|
||||
Use the [production Compose file](apps/web/docker-compose.yml) behind an HTTPS reverse proxy. Set `url.app` to the public admin origin and put your short-link hosts under `domains`. They can share a host or use separate ones. Keep the backend private; have the proxy preserve `Host` and set `X-Forwarded-Proto` and `X-Real-IP`. Put `PROTOCOL_HEADER=X-Forwarded-Proto` in `apps/web/.env`.
|
||||
|
||||
Keep `apps/web/data` writable by both containers and backed up. Use a stable, random `auth.secret` of at least 32 characters, passed in through the environment as in the example.
|
||||
|
||||
## Development
|
||||
|
||||
Use Node 26.5.0 and pnpm 11.9.0, pinned in `mise.toml`:
|
||||
|
||||
```sh
|
||||
mise install
|
||||
pnpm install --frozen-lockfile
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
Web listens on <http://localhost:5173>. Run the full local checks with:
|
||||
|
||||
```sh
|
||||
pnpm verify
|
||||
```
|
||||
|
||||
The current production smoke test uses HTTP requests and does not need an
|
||||
installed browser.
|
||||
|
||||
## Docker
|
||||
|
||||
From the repository root:
|
||||
|
||||
```sh
|
||||
docker compose -f apps/web/docker-compose.dev.yml up --build
|
||||
```
|
||||
|
||||
Development uses source bind mounts and Vite hot reload on localhost:5173. Set
|
||||
`LOCAL_UID` and `LOCAL_GID` when the host user is not 1000:1000.
|
||||
|
||||
For a local production build on localhost:3000:
|
||||
|
||||
```sh
|
||||
docker compose -f apps/web/docker-compose.yml up --build
|
||||
```
|
||||
|
||||
The production container runs as a non-root user with a read-only filesystem.
|
||||
|
||||
The optional `mise docker` task in `apps/web` follows the When development flow:
|
||||
install fnox and create an ignored `docker-compose.dev.local.yml` for local values,
|
||||
then run `mise docker up --build`. Direct Compose does not require that override.
|
||||
|
||||
## Configuration contract
|
||||
|
||||
The shared `@goto/config` package validates the YAML contract; the web runtime does
|
||||
not load it yet. See [the example](examples/goto.yaml) and
|
||||
[the package API](packages/config/README.md).
|
||||
|
||||
Configuration is a single `config/goto.yaml` with top-level keys `version`,
|
||||
`url`, `appearance`, `auth`, `database`, `analytics`, `link_defaults`, `fallback`,
|
||||
and `domains`. Unknown fields and null values fail validation. Auth declares
|
||||
exactly one OIDC or shared-credentials provider; `auth.secret` is optional and
|
||||
is not generated by the loader.
|
||||
|
||||
Redirect status and query forwarding inherit built-in → global → domain → link.
|
||||
Fallback inherits only through domain scope. Defaults are 302, forwarding off,
|
||||
and fallback 404. Explicit false overrides true. Analytics defaults to enabled
|
||||
with 90 days of retention.
|
||||
|
||||
String values support `${VAR}`, `${VAR:-fallback}`, and `$$`; keys stay literal.
|
||||
Paths use readable logical text such as `/café`, not URL-escape decoding in YAML.
|
||||
Noncanonical spellings such as `/my docs` and `/docs/` fail instead of being
|
||||
rewritten. `/` remains allowed. The loader reports a simple configuration error;
|
||||
it does not print expanded secrets or parser snippets.
|
||||
|
||||
## Changes and checks
|
||||
|
||||
Prefer unit tests. Use E2E only for critical boundaries unit tests cannot prove,
|
||||
without repeating unit assertions or testing third-party internals. Tests should
|
||||
encourage readable, testable code and catch regressions; coverage reports are a
|
||||
diagnostic, not a percentage target.
|
||||
|
||||
`pnpm lint`, `pnpm check`, `pnpm test:coverage`, and `pnpm test:e2e` run the individual
|
||||
checks. GitHub Actions and Woodpecker run them for pull requests, matching changes
|
||||
on main, and web release tags.
|
||||
|
||||
After the checks pass, pushes to main build the production image as `latest`.
|
||||
Stable tags such as `@goto/web@1.2.3` must match `apps/web/package.json` and publish
|
||||
image tags `1.2.3`, `1.2`, and `1`. Release tags do not update `latest`. Pull requests
|
||||
do not build or publish Docker images, following When's pipeline.
|
||||
|
||||
GitHub publishes to `ghcr.io/eleith/goto` using its scoped `GITHUB_TOKEN`.
|
||||
Woodpecker publishes to `git.eleith.com/eleith.private/goto` using the configured
|
||||
`gitea_docker_registry` secret. Its main/tag success and failure notifications use
|
||||
`woodpecker_email_dsn`, `woodpecker_email_from_address`,
|
||||
`woodpecker_email_from_name`, and `woodpecker_email_recipient`. These secrets and
|
||||
registry permissions must be provisioned by the operator.
|
||||
|
||||
Use `pnpm changeset` to record an application change. `pnpm version:apps` updates
|
||||
versions/changelogs and `pnpm tag:apps` creates release tags; those commands are
|
||||
release operations, not part of everyday development.
|
||||
The [development Compose file](apps/web/docker-compose.dev.yml) reloads the app as you edit. For local tooling, [mise](mise.toml) pins Node and pnpm. `pnpm verify` runs the checks, including Chromium browser tests.
|
||||
@@ -1,39 +1,7 @@
|
||||
# @goto/config
|
||||
|
||||
Shared TypeBox schemas, YAML loading, environment interpolation, and effective
|
||||
redirect defaults for the Goto workspace.
|
||||
GoTo’s shared YAML loader. Both the web app and the worker use it.
|
||||
|
||||
- `parseConfig(source, options)` parses and validates YAML text.
|
||||
- `validateConfig(input, options)` validates an already parsed value.
|
||||
- `loadConfigFile(path?, options)` reads a file and resolves its database path.
|
||||
Start with the [example YAML](../../examples/goto.yaml) or look up a field in the [schema](src/config.schema.json).
|
||||
|
||||
Options accept an explicit `env` and `cwd`. Without them, the current process
|
||||
supplies those values. The default file is `config/goto.yaml`, overridable with
|
||||
`CONFIG_PATH`. Relative database paths resolve against the config directory's
|
||||
parent, not the shell's working directory.
|
||||
|
||||
The result has two parts:
|
||||
|
||||
- `configuration`: validated, defaulted server configuration. Omitted domain/link
|
||||
override values stay omitted. This includes authentication secrets and must not
|
||||
be sent to the browser.
|
||||
- `domains`: canonical host keys with effective link settings and `provenance`
|
||||
(`builtin`, `global`, `domain`, or `link`). Explicit false overrides true.
|
||||
|
||||
Inputs are not mutated. Snapshot freezing/publication is the runtime's concern.
|
||||
|
||||
Keys are literal. String values support `${VAR}`, `${VAR:-fallback}`, and `$$`;
|
||||
variable names follow the reference convention of uppercase letters, digits and
|
||||
underscores. Empty values count as set; replacement values are not expanded again.
|
||||
There is no numeric/boolean coercion or implicit auth-secret environment lookup.
|
||||
Omitting `auth.secret` leaves it unset for runtime generation.
|
||||
|
||||
Paths are logical text, not encoded URL strings. They start with one slash, do
|
||||
not end in a slash except `/`, and have no spaces, control characters, backslashes,
|
||||
dot segments, or `:?#[]@`. Unicode, literal percent characters, and internal
|
||||
slashes are allowed. Invalid keys fail validation; nothing is silently rewritten.
|
||||
Request decoding is not performed by this package's config loader.
|
||||
|
||||
Failures throw the same generic `ConfigError` without authored keys, locations,
|
||||
expanded values, or YAML parser snippets. There are no repair modes, redaction
|
||||
frameworks, or path-specific exception classes.
|
||||
Use `loadConfigFile()` to read a file, `parseConfig()` for YAML text, or `loadConfig()` for an already parsed value. The loader applies defaults and prepares the redirect lookup. The result includes server-only settings, including secrets. Don’t send it to the browser.
|
||||
Reference in new issue
Block a user