From 11bd45b46068a0508d1a6787ee16d0d8733497c0 Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Thu, 23 Jul 2026 18:55:17 +0800 Subject: [PATCH] feat(db): switch runtime storage to SQLite repository Point routes, scheduler, and push service at fcmTokensSqlite so the service no longer reads or writes the JSON store. --- src/db/fcmTokensSqlite.ts | 16 +++++++++++++--- src/routes/debug.ts | 2 +- src/routes/notifications.ts | 2 +- src/scheduler.ts | 2 +- src/services/pushService.ts | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/db/fcmTokensSqlite.ts b/src/db/fcmTokensSqlite.ts index c2f1272..6927bf6 100644 --- a/src/db/fcmTokensSqlite.ts +++ b/src/db/fcmTokensSqlite.ts @@ -1,13 +1,23 @@ import { randomUUID } from "node:crypto"; -import type { StoredRow } from "./fcmTokens.js"; import { getDatabase } from "./sqlite.js"; /** * SQLite-backed FCM registration repository. - * This is the service's storage backend; the JSON repository remains only until switch-over. + * This is the service's storage backend. + * The JSON repository is unused at runtime and will be removed in a later cleanup. * There is no production-data migration from JSON. */ -export type { StoredRow }; +export type StoredRow = { + id: string; + userId: string; + deviceId: string; + fcmToken: string; + platform: string; + testMode?: boolean; + createdAt: string; + updatedAt: string; + lastNotifiedAt?: number; +}; type DbRow = { id: string; diff --git a/src/routes/debug.ts b/src/routes/debug.ts index bba8627..f644df9 100644 --- a/src/routes/debug.ts +++ b/src/routes/debug.ts @@ -1,5 +1,5 @@ import express, { Router } from "express"; -import { db } from "../db/fcmTokens.js"; +import { db } from "../db/fcmTokensSqlite.js"; import { requireAuth, requireAuthOrNotificationLocalTest, diff --git a/src/routes/notifications.ts b/src/routes/notifications.ts index a2f3847..40389ff 100644 --- a/src/routes/notifications.ts +++ b/src/routes/notifications.ts @@ -1,5 +1,5 @@ import express, { Router } from "express"; -import { db } from "../db/fcmTokens.js"; +import { db } from "../db/fcmTokensSqlite.js"; import { requireAuthOrNotificationLocalTest, requireEndorserAuth, diff --git a/src/scheduler.ts b/src/scheduler.ts index 52795b6..e80c260 100644 --- a/src/scheduler.ts +++ b/src/scheduler.ts @@ -1,4 +1,4 @@ -import { db } from "./db/fcmTokens.js"; +import { db } from "./db/fcmTokensSqlite.js"; import { sendPushToDevice } from "./services/pushService.js"; import { errorMessage, formatElapsedMs } from "./util/formatElapsed.js"; diff --git a/src/services/pushService.ts b/src/services/pushService.ts index b7f64dd..81089c3 100644 --- a/src/services/pushService.ts +++ b/src/services/pushService.ts @@ -1,4 +1,4 @@ -import { db, type StoredRow } from "../db/fcmTokens.js"; +import { db, type StoredRow } from "../db/fcmTokensSqlite.js"; import { errorMessage, formatElapsedMs } from "../util/formatElapsed.js"; import { maskToken } from "../util/maskToken.js"; import { messaging } from "./firebase.js";