aboutsummaryrefslogtreecommitdiffstats
path: root/server.js
diff options
context:
space:
mode:
authorpack <pack@packgekko.xyz>2026-08-12 17:06:50 +0000
committerpack <pack@packgekko.xyz>2026-08-12 17:06:50 +0000
commit5611527e313c4add16c432e5cf9d55a987558c02 (patch)
tree59ad054325096b6305277b94982bbe7f7f585f59 /server.js
parentd3adc16a08d95d6e331de55d7d3bf05a66a874a8 (diff)
downloadcrud-5611527e313c4add16c432e5cf9d55a987558c02.tar.gz
final commit
Diffstat (limited to '')
-rw-r--r--server.js20
1 files changed, 11 insertions, 9 deletions
diff --git a/server.js b/server.js
index a663c83..fbe0d63 100644
--- a/server.js
+++ b/server.js
@@ -1,19 +1,21 @@
const express = require('express');
const session = require('express-session');
+const requireAuth = require('./middleware/auth');
+
const app = express();
-app.use(express.urlencoded({ extended: true }));
app.use(express.json());
+app.use(express.static('public'));
+
app.use(session({
- secret: 'change-this-secret',
+ secret: 'zxcv1234',
resave: false,
- saveUninitialized: false
+ saveUninitialized: false,
+ cookie: { maxAge: 1000 * 60 * 60 * 24 } /* 1 day. */
}));
-const authRoutes = require('./routes/auth');
-const taskRoutes = require('./routes/tasks');
-
-app.use('/auth', authRoutes);
-app.use('/tasks', taskRoutes);
+app.use('/auth', require('./routes/auth'));
+app.use('/tasks', requireAuth, require('./routes/tasks')); /* protect task routes. */
-app.listen(3000, () => console.log('running on http://localhost:3000'));
+const PORT = process.env.PORT || 3000;
+app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`));