aboutsummaryrefslogtreecommitdiffstats
path: root/server.js
blob: fbe0d63a418676e30f39986ec2d22f6a45c772c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const express = require('express');
const session = require('express-session');
const requireAuth = require('./middleware/auth');

const app = express();

app.use(express.json());
app.use(express.static('public'));

app.use(session({
  secret: 'zxcv1234',
  resave: false,
  saveUninitialized: false,
  cookie: { maxAge: 1000 * 60 * 60 * 24 } /* 1 day. */
}));

app.use('/auth', require('./routes/auth'));
app.use('/tasks', requireAuth, require('./routes/tasks'));  /* protect task routes. */

const PORT = process.env.PORT || 3000;
app.listen(PORT, () => console.log(`Server running on http://localhost:${PORT}`));