-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
63 lines (51 loc) · 1.01 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
56
57
58
59
60
61
62
63
/**
* @license Apache-2.0
* @copyright Seif Eddine Mouihbi 2024
*/
'use strict';
/**
* node modules
*/
const cors = require('cors');
const cookieParser = require('cookie-parser');
/**
* custom modules
*/
const login = require('./src/routes/login.route');
const auth = require('./src/routes/auth.route');
const authenticatedUser = require('./src/middlewares/auth_user.middleware');
const home = require('./src/routes/home.route');
//Initial express app
const express = require('express');
const app = express();
/**
* EJS Setting
*/
app.set('view engine', 'ejs');
/**
* Setting static directory
*/
app.use(express.static(`${__dirname}/public`));
/**
* Enable cors & cookie parser
*/
app.use(cors()).use(cookieParser());
/**
* Login Page
*/
app.use('/login', login);
/**
* Auth page
*/
app.use('/auth', auth);
/**
* check user is authenticated
*/
app.use(authenticatedUser);
/**
* Home page
*/
app.use('/', home);
app.listen(8080, () => {
console.log(`Server Listening at http://localhost:8080`);
});