diff --git a/docs/APPS.md b/docs/APPS.md index 851bebf..4562efa 100644 --- a/docs/APPS.md +++ b/docs/APPS.md @@ -48,6 +48,7 @@ export default app.defaults - `PORT` - your assigned port (3001-3100) - `APPS_DIR` - path to `/apps` directory +- `DATA_DIR` - per-app data directory (`toes//`) ## health checks diff --git a/docs/ENV.md b/docs/ENV.md index a53f4ab..af47af2 100644 --- a/docs/ENV.md +++ b/docs/ENV.md @@ -39,3 +39,13 @@ DEBUG=true ``` Keys are uppercased automatically. Quotes around values are stripped. + +## Built-in variables + +These are set automatically by Toes — you don't need to configure them: + +- `PORT` - assigned port (3001-3100) +- `APPS_DIR` - path to the `/apps` directory +- `DATA_DIR` - per-app data directory (`toes//`) for storing persistent data +- `TOES_URL` - base URL of the Toes server +- `TOES_DIR` - path to the toes config directory diff --git a/docs/TOOLS.md b/docs/TOOLS.md index 9bc4970..6dbe0ce 100644 --- a/docs/TOOLS.md +++ b/docs/TOOLS.md @@ -34,12 +34,20 @@ app.get('/', c => { }) ``` +## environment + +- `PORT` - your assigned port +- `APPS_DIR` - path to `/apps` directory +- `DATA_DIR` - per-app data directory (`toes//`) +- `TOES_URL` - base URL of the Toes server +- `TOES_DIR` - path to the toes config directory + ## accessing app files Always go through the `current` symlink: ```ts -const APPS_DIR = process.env.APPS_DIR ?? '.' +const APPS_DIR = process.env.APPS_DIR! const appPath = join(APPS_DIR, appName, 'current') ``` diff --git a/src/server/apps.ts b/src/server/apps.ts index 0badfc8..abb5d4d 100644 --- a/src/server/apps.ts +++ b/src/server/apps.ts @@ -597,7 +597,7 @@ async function runApp(dir: string, port: number) { const proc = Bun.spawn(['bun', 'run', 'toes'], { cwd, - env: { ...process.env, ...appEnv, PORT: String(port), NO_AUTOPORT: 'true', APPS_DIR, TOES_DIR, TOES_URL }, + env: { ...process.env, ...appEnv, PORT: String(port), NO_AUTOPORT: 'true', APPS_DIR, DATA_DIR: join(process.env.DATA_DIR ?? '.', 'toes', dir), TOES_DIR, TOES_URL }, stdout: 'pipe', stderr: 'pipe', })