const express = require('express'); const app = express(); const expressWs = require('express-ws')(app); const session = require('express-session'); const apiRoutes = require('./routes/api.js'); const port = process.env.PORT || 3001; // Use the port provided by the host or default to 3000 const sqlite = require('better-sqlite3'); const db = new sqlite('the_big_db.db'); const SqliteStore = require('better-sqlite3-session-store')(session); app.use(express.json()); app.use(session({ store: new SqliteStore({ client: db, expired: { clear: true, intervalMs: 15*60*1000 } }), secret: process.env.SESSION_DATA_SECRET, resave: false, saveUninitialized: false })); app.use("/api", apiRoutes); app.listen(port, () => { console.log(`Server listening on port ${port}`); });