-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
54 lines (40 loc) · 1.55 KB
/
server.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
import express from 'express';
import path from 'path';
import cookieParser from 'cookie-parser';
import newRoute from './routes/newRoute.js';
import main from './routes/main.js';
import reservations from './routes/reservations.js';
import login from './routes/login.js';
import registration from './routes/registration.js';
import logout from './routes/logout.js';
import apiRoutes from './api/index.js';
import { decodeJWTToken, decodeJWTTokenPopup } from './middleware/authentication.js';
const app = express();
app.use(cookieParser());
// EJS sablonmotor beallitasa
app.set('view engine', 'ejs');
app.set('views', path.join(process.cwd(), 'views'));
// a static mappabol adjuk a HTML allomanyokat
app.use(express.static(path.join(process.cwd(), 'static')));
// feldolgozhatova teszi a body tartalmat
app.use(express.urlencoded({ extended: true }));
// formfeldolgozas router segitsegevel
app.use('/new-route', decodeJWTToken, newRoute);
// foglalas kezelese routerrel
app.use('/reservations', decodeJWTTokenPopup, reservations);
// bejelentkezes kezelese
app.use('/login', login);
app.use('/logout', logout);
// regisztracio kezelese
app.use('/registration', registration);
// fooldal kezelese routerrel
app.use('/', decodeJWTToken, main);
// API hivasok kezelese
app.use('/api', apiRoutes);
// barmilyen mas nem letezo utvonal
app.get('/*', (_req, res) => {
res.status(404).send('This page can\'t be found');
});
app.listen(8080, () => {
console.log('Server listening on http://localhost:8080/ ...');
});