-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
83 lines (74 loc) · 1.88 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**
* @author Ana Silva
*/
/**
* @var express
* node framework to make my life easier
* @var morgan
* Logger middleware.
* @var bodyParser
* Parse incoming request bodies in a middleware before your handlers, available under the req.body property.
* @var port
* Sets the port to be used by the application
* @requires dotenv
* Load enviroment file
*/
require('dotenv').load();
var express = require("express");
var morgan = require("morgan");
var bodyParser = require("body-parser");
var port = process.env.PORT || 6000;
var request = require("request");
var session = require("express-session");
var passport = require("passport");
var path = require("path");
var flash = require("connect-flash");
require('./config/auth.config');
const datasetModel = require('./model/dataset.model');
/**
* Loads all the api specific routes
*/
var api = require('./routes/api.routes');
var auth = require('./routes/auth.routes');
var app = express();
/**
* Loads other dependencies.
*/
app.use(require('cookie-parser')());
const expressSession = require("express-session");
app.use(expressSession({secret: process.env.SECRET_KEY}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use(session({secret: process.env.ANOTHER_SECRET_KEY}));
app.set('view engine', 'pug');
app.set('view options', { layout: false });
if (process.env.NODE_ENV !== 'production') {
require('dotenv').load();
}
/**
* Parsing body
*/
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
/**
* log stuff
*/
app.use(morgan('dev'));
/**
* bind specific routes into the main file
*/
app.use('/api', api);
app.use('/auth', auth);
/**
* index route
*/
app.get('/', (req, res) => {
res.send("Application works");
});
/**
* application listening on the port
*/
app.listen(port, () => {
console.log("Server running on port " +port);
});