]> git.cworth.org Git - zombocom-ai/blobdiff - index.js
Use a single function for the tardis app
[zombocom-ai] / index.js
index b80943fb6b3c8da53cd8eb0fa3963560dfd7aa9b..04fe9bb0c65152eb1537d98a08e2315ca3430655 100644 (file)
--- a/index.js
+++ b/index.js
@@ -74,7 +74,15 @@ const session_middleware =  session(
     {store: new FileStore,
      secret: process.env.ZOMBOCOM_SESSION_SECRET,
      resave: false,
-     saveUninitialized: true
+     saveUninitialized: true,
+     rolling: true,
+     // Let each cookie live for a full month
+     cookie: {
+         path: '/',
+         httpOnly: true,
+         secure: false,
+         maxAge: 1000 * 60 * 60 * 24 * 30
+     }
     });
 
 app.use(session_middleware);
@@ -113,17 +121,12 @@ app.get('/index.html', (req, res) => {
     res.sendFile(__dirname + '/index.html');
 });
 
-app.get('/tardis', (req, res) => {
+function tardis_app(req, res) {
     res.sendFile(__dirname + '/tardis.html');
-});
-
-app.get('/tardis/', (req, res) => {
-    res.sendFile(__dirname + '/tardis.html');
-});
+}
 
-app.get('/tardis/index.html', (req, res) => {
-    res.sendFile(__dirname + '/tardis.html');
-});
+app.get('/tardis', tardis_app);
+app.get('/tardis/', tardis_app);
 
 io.on('connection', (socket) => {
 
@@ -229,10 +232,10 @@ io.on('connection', (socket) => {
             } else {
 
                 // Inject the target seed for the "dice" prompt once every
-                // 6 requests for a random seed (and only if the word
+                // 4 requests for a random seed (and only if the word
                 // "dice" does not appear in the prompt).
                 if (!code && !prompt.toLowerCase().includes("dice")) {
-                    if (state.images.length % 6 == 0) {
+                    if (state.images.length % 4 == 0) {
                         code = 319630254;
                     }
                 }