I have a node js code that authenticates with cookies and sessions:
import express from "express";
import session from "express-session";
import postgreSession from "connect-pg-simple";
import { Pool } from "pg";
const app = express();
const PostgreSession = postgreSession(session);
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
app.use(
session({
store: new PostgreSession({ pool: pool, createTableIfMissing: true }),
secret: process.env.SESSION_SECRET,
resave: false,
saveUninitialized: false,
cookie: { httpOnly: true, secure: false, maxAge: 60 * 60 * 1000 },
}),
);
and prisma schema. Do I really have to create new model Sessions to keep in sync database and schema? Is there a better approach, something where the prisma(or maybe some other frameworks) handle everything related to keeping in sync sessions in database and schema themselves? Some say to manually create model in prisma:
model Session {
sid String @id
sess Json
expire DateTime
@@map("session")
}
I don't know why, it just looks a bit ugly.