-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
56 lines (46 loc) · 1.55 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
const express = require('express')
const path = require('path')
var bodyParser = require('body-parser');
const cookieParser = require("cookie-parser");
const csrf = require("csurf");
const csrfMiddleware = csrf({ cookie: true });
const PORT = 3000
//Requiring Routes.
const circuitRouter = require('./routes/circuit')
const cloudRouter = require('./routes/cloud')
const functionRouter = require('./routes/function')
const analysisRouter = require('./routes/analysis')
const exampleRouter = require('./routes/example')
const docRouter = require('./routes/docs')
const hiwRouter = require('./routes/hiw')
const infoRouter = require('./routes/info')
// Initializing app
const app = express();
// Setting up our view engine and static files
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use('/public', express.static('public'));
// Parses the body for POST, PUT, DELETE, etc.
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(bodyParser.raw());
// cookie parser and csrf middleware
app.use(cookieParser());
app.use(csrfMiddleware);
// intercept all requests and verify csrf token
app.all("*", (req, res, next) => {
res.cookie("XSRF-TOKEN", req.csrfToken());
next();
});
// Telling express to use Routes
app.use('/',circuitRouter);
app.use('/',cloudRouter);
app.use('/',functionRouter);
app.use('/',analysisRouter);
app.use('/',exampleRouter);
app.use('/',docRouter);
app.use('/',hiwRouter);
app.use('/',infoRouter);
app.listen(PORT, () => {
console.log(`App listening at http://localhost:${PORT}`)
})