-
Notifications
You must be signed in to change notification settings - Fork 0
/
serverReact.js
78 lines (47 loc) · 2.32 KB
/
serverReact.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
//app.js
const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');
const queryString = require('query-string');
const path = require('path');
const axios = require('axios');
const config = require('config');
const { google } = require('googleapis');
var session = require('express-session');
//Security Block
const googleConfig = config.get("rutine.googleConfig");
const OAuth2Data = {"web":{"client_id":googleConfig.clientId,"project_id":"rutine","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":googleConfig.clientSecret,"redirect_uris":["http://localhost:8080/auth/google/callback"],"javascript_origins":["http://localhost:8080"]}}
const CLIENT_ID = OAuth2Data.web.client_id;
const CLIENT_SECRET = OAuth2Data.web.client_secret;
const REDIRECT_URL = OAuth2Data.web.redirect_uris;
const oAuth2Client = new google.auth.OAuth2(CLIENT_ID, CLIENT_SECRET, REDIRECT_URL)
var authed = false;
//End Security Block
const routes = require('./Routes/home.js'); // Imports routes for the products
const app = express();
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({
extended: true
}));
const mongoConfig = config.get('rutine.mongoConfig');
// Set up mongoose connection
const mongoose = require('mongoose');
//mongoose.connect('mongodb+srv://eli:[email protected]/Tasks?retryWrites=true&w=majority', { useNewUrlParser: true, useUnifiedTopology: true })
mongoose.connect(mongoConfig.host, { useNewUrlParser: true, useUnifiedTopology: true })
mongoose.Promise = global.Promise;
mongoose.set('useFindAndModify', false);
let db = mongoose.connection;
db.on('error', console.error.bind(console, 'MongoDB connection error:'));
app.use(bodyParser.json());
//app.use(bodyParser.urlencoded({extended: false}));
app.use('/', routes);
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
let port = process.env.PORT || 8080;
app.use(express.static(__dirname));
app.listen(port, () => {
console.log('[+]Server is up and running on port number ' + port);
});