Compare commits
6
Commits
sqlite-storage
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a93a46ba39 | ||
|
|
9c7c7fa271 | ||
|
|
76d3447d78 | ||
|
|
6e4e1e7f1b | ||
|
|
a45150e25f | ||
|
|
d8989f587e |
+1
-1
@@ -10,7 +10,7 @@ PORT=3003
|
||||
|
||||
# Directory for the SQLite FCM registration database (default: ./data).
|
||||
# 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.
|
||||
# NODE_ENV=test-local
|
||||
|
||||
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
|
||||
## [0.1.4] - 2026.08.07
|
||||
### Changed
|
||||
- Renamed `FCM_TOKEN_DATA_DIR` env var to `NOTIFY_DATA_DIR`
|
||||
|
||||
|
||||
## [0.1.3] - 2026.07.30
|
||||
### Changed
|
||||
- Persistence changed from file to SQLite
|
||||
|
||||
|
||||
## [0.1.2] - 2026.07.16
|
||||
### Added
|
||||
- Validation via Endorser service, with new ENDORSER_URL variable
|
||||
|
||||
@@ -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 `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
|
||||
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.
|
||||
|
||||
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
|
||||
|
||||
@@ -38,11 +38,11 @@ Set `NODE_ENV=test-local` in `.env` to bypass ethr JWT *expiry* verification dur
|
||||
|
||||
| Path | Description |
|
||||
|---|---|
|
||||
| `{FCM_TOKEN_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) |
|
||||
| `{FCM_TOKEN_DATA_DIR}/notify.sqlite-shm` | Shared-memory file used with WAL mode |
|
||||
| `{NOTIFY_DATA_DIR}/notify.sqlite` | Primary SQLite database (default dir: `./data`) |
|
||||
| `{NOTIFY_DATA_DIR}/notify.sqlite-wal` | WAL journal (present while the process is running) |
|
||||
| `{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)
|
||||
|
||||
@@ -62,11 +62,11 @@ There is **no automatic migration** from the old JSON file (`fcm-tokens.json`).
|
||||
|
||||
### 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).
|
||||
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
|
||||
|
||||
@@ -77,7 +77,7 @@ pnpm install --prod
|
||||
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:
|
||||
|
||||
@@ -88,7 +88,7 @@ docker run --env-file notify-wakeup-api.env -p 3003:3003 \
|
||||
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:
|
||||
|
||||
@@ -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. |
|
||||
| `PORT` | HTTP port (default: `3003`). |
|
||||
| `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`). |
|
||||
|
||||
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "notification-wakeup-service",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "notification-wakeup-service",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.4",
|
||||
"dependencies": {
|
||||
"@peculiar/asn1-ecc": "^2.7.0",
|
||||
"@peculiar/asn1-schema": "^2.7.0",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "notification-wakeup-service",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.4",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "pnpm@11.4.0",
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ import path from "node:path";
|
||||
import Database from "better-sqlite3";
|
||||
|
||||
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 SCHEMA_SQL = `
|
||||
|
||||
Reference in New Issue
Block a user