26 lines
530 B
JavaScript
26 lines
530 B
JavaScript
const express = require('express');
|
|
const session = require('express-session');
|
|
const app = express();
|
|
const dotenv = require('dotenv');
|
|
|
|
// Load environment variables
|
|
dotenv.config();
|
|
|
|
// Ensure that SESSION_SECRET is defined
|
|
if (!process.env.SESSIONS_SECRET) {
|
|
console.error('FATAL ERROR: SESSIONS_SECRET is not defined.');
|
|
process.exit(1);
|
|
}
|
|
|
|
// Middleware
|
|
app.use(express.json());
|
|
app.use(
|
|
session({
|
|
secret: process.env.SESSIONS_SECRET,
|
|
resave: false,
|
|
saveUninitialized: true,
|
|
})
|
|
);
|
|
|
|
module.exports = app;
|