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.
This commit is contained in:
Jose Olarte III
2026-07-23 18:55:17 +08:00
parent 5a3c22a4e3
commit 11bd45b460
5 changed files with 17 additions and 7 deletions

View File

@@ -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;

View File

@@ -1,5 +1,5 @@
import express, { Router } from "express";
import { db } from "../db/fcmTokens.js";
import { db } from "../db/fcmTokensSqlite.js";
import {
requireAuth,
requireAuthOrNotificationLocalTest,

View File

@@ -1,5 +1,5 @@
import express, { Router } from "express";
import { db } from "../db/fcmTokens.js";
import { db } from "../db/fcmTokensSqlite.js";
import {
requireAuthOrNotificationLocalTest,
requireEndorserAuth,

View File

@@ -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";

View File

@@ -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";