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:
@@ -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;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import express, { Router } from "express";
|
||||
import { db } from "../db/fcmTokens.js";
|
||||
import { db } from "../db/fcmTokensSqlite.js";
|
||||
import {
|
||||
requireAuth,
|
||||
requireAuthOrNotificationLocalTest,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import express, { Router } from "express";
|
||||
import { db } from "../db/fcmTokens.js";
|
||||
import { db } from "../db/fcmTokensSqlite.js";
|
||||
import {
|
||||
requireAuthOrNotificationLocalTest,
|
||||
requireEndorserAuth,
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user