chore: rename FCM_TOKEN_DATA_DIR env var to NOTIFY_DATA_DIR

Align the data-directory env name with notify.sqlite; default path remains ./data.
This commit is contained in:
Jose Olarte III
2026-08-04 17:31:14 +08:00
parent a45150e25f
commit 6e4e1e7f1b
3 changed files with 13 additions and 13 deletions

View File

@@ -10,7 +10,7 @@ PORT=3003
# Directory for the SQLite FCM registration database (default: ./data). # Directory for the SQLite FCM registration database (default: ./data).
# Creates notify.sqlite (plus -wal/-shm while the process is running). # Creates notify.sqlite (plus -wal/-shm while the process is running).
# FCM_TOKEN_DATA_DIR=./data # NOTIFY_DATA_DIR=./data
# Set to "test-local" to bypass ethr JWT expiry verification in local dev only. # Set to "test-local" to bypass ethr JWT expiry verification in local dev only.
# NODE_ENV=test-local # NODE_ENV=test-local

View File

@@ -13,7 +13,7 @@ Here is one way to generate the contents: `cat your-downloaded-key.json | jq -c
Optionally set `ENDORSER_URL` if you are not using the default production Endorser API (`https://api.endorser.ch`). Optionally set `ENDORSER_URL` if you are not using the default production Endorser API (`https://api.endorser.ch`).
Optionally set `FCM_TOKEN_DATA_DIR` if you want the SQLite database somewhere other than `./data`. Optionally set `NOTIFY_DATA_DIR` if you want the SQLite database somewhere other than `./data`.
```bash ```bash
pnpm install pnpm install
@@ -22,7 +22,7 @@ pnpm run dev
The server starts on `http://localhost:3003` (or the port in `PORT`). Hot-reloads on file changes. The server starts on `http://localhost:3003` (or the port in `PORT`). Hot-reloads on file changes.
On first use, the service creates `FCM_TOKEN_DATA_DIR` (default `./data`) and the SQLite file `notify.sqlite` with the required schema. On first use, the service creates `NOTIFY_DATA_DIR` (default `./data`) and the SQLite file `notify.sqlite` with the required schema.
### Authentication ### Authentication
@@ -38,11 +38,11 @@ Set `NODE_ENV=test-local` in `.env` to bypass ethr JWT *expiry* verification dur
| Path | Description | | Path | Description |
|---|---| |---|---|
| `{FCM_TOKEN_DATA_DIR}/notify.sqlite` | Primary SQLite database (default dir: `./data`) | | `{NOTIFY_DATA_DIR}/notify.sqlite` | Primary SQLite database (default dir: `./data`) |
| `{FCM_TOKEN_DATA_DIR}/notify.sqlite-wal` | WAL journal (present while the process is running) | | `{NOTIFY_DATA_DIR}/notify.sqlite-wal` | WAL journal (present while the process is running) |
| `{FCM_TOKEN_DATA_DIR}/notify.sqlite-shm` | Shared-memory file used with WAL mode | | `{NOTIFY_DATA_DIR}/notify.sqlite-shm` | Shared-memory file used with WAL mode |
`FCM_TOKEN_DATA_DIR` defaults to `./data` (relative to the process working directory). The `data/` directory is gitignored. `NOTIFY_DATA_DIR` defaults to `./data` (relative to the process working directory). The `data/` directory is gitignored.
### Schema (high level) ### Schema (high level)
@@ -62,11 +62,11 @@ There is **no automatic migration** from the old JSON file (`fcm-tokens.json`).
### Backup ### Backup
Persist or back up the SQLite files under `FCM_TOKEN_DATA_DIR`: Persist or back up the SQLite files under `NOTIFY_DATA_DIR`:
1. Prefer stopping the service, then copy `notify.sqlite` (and any `-wal` / `-shm` sidecars if present). 1. Prefer stopping the service, then copy `notify.sqlite` (and any `-wal` / `-shm` sidecars if present).
2. Or, while the service is running, copy **all three** files (`notify.sqlite`, `-wal`, `-shm`) together so the backup stays consistent under WAL mode. 2. Or, while the service is running, copy **all three** files (`notify.sqlite`, `-wal`, `-shm`) together so the backup stays consistent under WAL mode.
3. For Docker, mount a volume at the data directory (or set `FCM_TOKEN_DATA_DIR` to a mounted path) so registrations survive container recreation. 3. For Docker, mount a volume at the data directory (or set `NOTIFY_DATA_DIR` to a mounted path) so registrations survive container recreation.
## Production ## Production
@@ -77,7 +77,7 @@ pnpm install --prod
pnpm start pnpm start
``` ```
Ensure `FCM_TOKEN_DATA_DIR` points at a durable location (or accept the default `./data` next to the process cwd). Ensure `NOTIFY_DATA_DIR` points at a durable location (or accept the default `./data` next to the process cwd).
Or with Docker: Or with Docker:
@@ -88,7 +88,7 @@ docker run --env-file notify-wakeup-api.env -p 3003:3003 \
notify-wakeup-api notify-wakeup-api
``` ```
Mount a volume over `/app/data` (or whatever path you set with `FCM_TOKEN_DATA_DIR`) so the SQLite database is not lost when the container is replaced. Mount a volume over `/app/data` (or whatever path you set with `NOTIFY_DATA_DIR`) so the SQLite database is not lost when the container is replaced.
Required environment variables: Required environment variables:
@@ -97,4 +97,4 @@ Required environment variables:
| `FIREBASE_SERVICE_ACCOUNT_JSON` | Inline service account JSON (one line). If unset, falls back to Application Default Credentials. | | `FIREBASE_SERVICE_ACCOUNT_JSON` | Inline service account JSON (one line). If unset, falls back to Application Default Credentials. |
| `PORT` | HTTP port (default: `3003`). | | `PORT` | HTTP port (default: `3003`). |
| `ENDORSER_URL` | Endorser API base URL used for auth checks on register/refresh (default: `https://api.endorser.ch`). | | `ENDORSER_URL` | Endorser API base URL used for auth checks on register/refresh (default: `https://api.endorser.ch`). |
| `FCM_TOKEN_DATA_DIR` | Directory for the SQLite database file `notify.sqlite` (default: `./data`). | | `NOTIFY_DATA_DIR` | Directory for the SQLite database file `notify.sqlite` (default: `./data`). |

View File

@@ -3,7 +3,7 @@ import path from "node:path";
import Database from "better-sqlite3"; import Database from "better-sqlite3";
const dataDir = const dataDir =
process.env.FCM_TOKEN_DATA_DIR ?? path.join(process.cwd(), "data"); process.env.NOTIFY_DATA_DIR ?? path.join(process.cwd(), "data");
const dbFile = path.join(dataDir, "notify.sqlite"); const dbFile = path.join(dataDir, "notify.sqlite");
const SCHEMA_SQL = ` const SCHEMA_SQL = `