|
@ -1,30 +1,21 @@ |
|
|
/** express app for routing */ |
|
|
|
|
|
const express = require("express"); |
|
|
const express = require("express"); |
|
|
|
|
|
|
|
|
/**session data for login and storing preferences*/ |
|
|
|
|
|
const session = require('express-session'); |
|
|
const session = require('express-session'); |
|
|
|
|
|
|
|
|
const configLoader = require('./configManager.js'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dotenv = require("dotenv").config(); |
|
|
const app = express(); |
|
|
const app = express(); |
|
|
|
|
|
|
|
|
/**Initializes sessions for login */ |
|
|
|
|
|
app.use(session( |
|
|
|
|
|
{ secret: configLoader.getSessionSecret(), |
|
|
|
|
|
cookie: { maxAge: 6000000 }} |
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.use(express.urlencoded()); //for easy retrieval of post and get data
|
|
|
|
|
|
|
|
|
const sessionProperties = { |
|
|
|
|
|
secret: process.env.SESSION_SECRET, |
|
|
|
|
|
cookie: { maxAge: 6000000 }, |
|
|
|
|
|
resave: false, |
|
|
|
|
|
saveUninitialized: false |
|
|
|
|
|
}; |
|
|
|
|
|
app.use(session(sessionProperties)); |
|
|
|
|
|
app.use(express.urlencoded({ extended: true })); |
|
|
app.use(express.json()); |
|
|
app.use(express.json()); |
|
|
|
|
|
|
|
|
app.use(express.static('public')); |
|
|
app.use(express.static('public')); |
|
|
|
|
|
|
|
|
const routes = require('./routes'); |
|
|
const routes = require('./routes'); |
|
|
app.use('/', routes); |
|
|
app.use('/', routes); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.listen(configLoader.getConfiguration().port, () => |
|
|
|
|
|
console.log(`App listening on port ${configLoader.getPort()}!`) |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
app.listen(process.env.PORT, () => console.log(`App listening on port ${process.env.PORT}!`)); |