mirror of
https://github.com/R0m1k3/Regisflow.git
synced 2026-10-22 06:38:21 +02:00
Update data management to use in-memory storage
Modify the application to use an in-memory storage solution, replacing the PostgreSQL database connection and data purging logic. This change impacts session management and data operations, introducing a fallback mechanism for when the database is unavailable. Replit-Commit-Author: Agent Replit-Commit-Session-Id: a388004f-01c5-42b1-b1d1-f18daf8bdd0c Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/0715008c-7244-40f4-befc-26c014852236/a388004f-01c5-42b1-b1d1-f18daf8bdd0c/ekgWmFH
This commit is contained in:
1 parent
430ab669aa
commit
40c7975bbc
5 files changed
+323
-45
No files matched your search
+6
-6
@@ -3,6 +3,7 @@ import { createServer, type Server } from "http";
|
||||
import { storage } from "./storage";
|
||||
import session from "express-session";
|
||||
import connectPg from "connect-pg-simple";
|
||||
import MemoryStore from "memorystore";
|
||||
import { loginSchema, insertUserSchema, insertStoreSchema, insertSaleSchema } from "@shared/schema";
|
||||
import { z } from "zod";
|
||||
import { createAutomaticBackup, getBackupStats } from "./backup-scheduler";
|
||||
@@ -48,13 +49,11 @@ declare global {
|
||||
}
|
||||
|
||||
export async function registerRoutes(app: Express): Promise<Server> {
|
||||
// Session configuration with PostgreSQL store
|
||||
const pgStore = connectPg(session);
|
||||
// Use memory store for sessions when database is not available
|
||||
const MemStoreClass = MemoryStore(session);
|
||||
app.use(session({
|
||||
store: new pgStore({
|
||||
conString: process.env.DATABASE_URL,
|
||||
createTableIfMissing: false,
|
||||
tableName: 'sessions',
|
||||
store: new MemStoreClass({
|
||||
checkPeriod: 86400000 // prune expired entries every 24h
|
||||
}),
|
||||
secret: process.env.SESSION_SECRET || 'fireworks-secret-key-2024',
|
||||
resave: false,
|
||||
@@ -323,6 +322,7 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
|
||||
// Parse and validate products
|
||||
const validatedProducts = products.map((product: any) => ({
|
||||
saleId: 0, // Will be set by storage layer
|
||||
typeArticle: product.typeArticle,
|
||||
categorie: product.categorie,
|
||||
quantite: parseInt(product.quantite),
|
||||
|
||||
Reference in new issue
Block a user