-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
55 lines (45 loc) · 1.41 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require('express');
const session = require('express-session');
const mongoose = require('mongoose');
const authRoutes = require('./routes/authRoutes');
const postRoutes = require('./routes/postRoutes');
const adminPanelRoutes = require('./routes/adminPanelRoutes');
const contentListRoutes = require('./routes/contentListRoutes');
const secret = require('./secret');
// const store = new session.MemoryStore();
const app = express();
const dbURI =
'mongodb+srv://bezsciemy-express:' + secret.dbPWD + '@bezsciemy-main.ydqazk8.mongodb.net/?retryWrites=true&w=majority';
const port = 3000;
console.log("B E Z Ś C I E M Y server starting...");
mongoose
.connect(dbURI, {
autoIndex: true
})
.then((result) => {
console.log('db connection established');
app.listen(port, () => {
console.log('B E Z Ś C I E M Y listeining to requests on %s', port);
});
})
.catch((err) => {
console.log(err);
});
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/public'));
app.use(
session({
secret: secret.cookieSecret,
resave: false,
//change last number to specify session max age in hours
cookie: { maxAge: 1000 * 3600 * 1 },
saveUninitialized: false,
// store
})
);
app.use('/administration', adminPanelRoutes);
app.use('/', contentListRoutes);
app.use('/auth', authRoutes);
app.use('/post', postRoutes);