mirror of
https://github.com/freedbygrace/DynamoDNS.git
synced 2026-08-20 14:42:16 +00:00
Migrate storage from in-memory to PostgreSQL database.
Replit-Commit-Author: Agent Replit-Commit-Session-Id: 9111ef36-26c8-4085-84ca-a35dc1fec1b5 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/7083d608-d6d3-4a6a-9a27-6286c5109627/37883948-9924-4429-8878-f2530cf6fe2b.jpg
This commit is contained in:
+6
-12
@@ -1,7 +1,4 @@
|
||||
import { randomBytes } from "crypto";
|
||||
import {
|
||||
users, organizations, domains, dnsRecords,
|
||||
providers, dnsHistory, apiTokens,
|
||||
type User, type InsertUser,
|
||||
type Organization, type InsertOrganization,
|
||||
type Domain, type InsertDomain,
|
||||
@@ -11,9 +8,7 @@ import {
|
||||
type DnsHistory
|
||||
} from "@shared/schema";
|
||||
import session from "express-session";
|
||||
import createMemoryStore from "memorystore";
|
||||
|
||||
const MemoryStore = createMemoryStore(session);
|
||||
import { DatabaseStorage } from "./database-storage";
|
||||
|
||||
export interface IStorage {
|
||||
// User management
|
||||
@@ -67,7 +62,7 @@ export interface IStorage {
|
||||
getDnsHistoryByDomain(domainId: number): Promise<DnsHistory[]>;
|
||||
|
||||
// Session store
|
||||
sessionStore: session.SessionStore;
|
||||
sessionStore: any;
|
||||
}
|
||||
|
||||
export class MemStorage implements IStorage {
|
||||
@@ -88,7 +83,7 @@ export class MemStorage implements IStorage {
|
||||
private apiTokenIdCounter: number;
|
||||
private historyIdCounter: number;
|
||||
|
||||
public sessionStore: session.SessionStore;
|
||||
public sessionStore: any;
|
||||
|
||||
constructor() {
|
||||
this.usersMap = new Map();
|
||||
@@ -107,9 +102,8 @@ export class MemStorage implements IStorage {
|
||||
this.apiTokenIdCounter = 1;
|
||||
this.historyIdCounter = 1;
|
||||
|
||||
this.sessionStore = new MemoryStore({
|
||||
checkPeriod: 86400000 // prune expired entries every 24h
|
||||
});
|
||||
// Session store is created in the DatabaseStorage class
|
||||
this.sessionStore = null;
|
||||
|
||||
// Initialize sample data
|
||||
this.initSampleData();
|
||||
@@ -386,4 +380,4 @@ export class MemStorage implements IStorage {
|
||||
}
|
||||
}
|
||||
|
||||
export const storage = new MemStorage();
|
||||
export const storage = new DatabaseStorage();
|
||||
|
||||
Reference in New Issue
Block a user