73 lines
1.8 KiB
JavaScript
73 lines
1.8 KiB
JavaScript
/**
|
|
* Created by WebStorm.
|
|
* User: martin
|
|
* Date: 14/05/2020
|
|
* Time: 09:13
|
|
|
|
*/
|
|
require('dotenv').config();
|
|
const express = require('express');
|
|
const bodyParser = require('body-parser');
|
|
const session = require('express-session');
|
|
const path = require('path');
|
|
const helmet = require('helmet');
|
|
const cors = require('cors');
|
|
|
|
const auth = require('./security/auth');
|
|
|
|
const app = express();
|
|
require('dotenv').config();
|
|
|
|
const serverPort = process.env.PORT || 8120;
|
|
|
|
const sitePath = 'dist';
|
|
|
|
app.use(cors());
|
|
app.use(helmet());
|
|
|
|
app.use(session({
|
|
'secret': ['D9B168FF8674CC0D842E7639781C54527CD8645E4A723F3A2871781257CF8B73', '2024B214451504643D45DD762EE901D42CE64D3655F00A624BF3EDCE302EB5DD', '62FB68528722F3BB869AC9AAE07C535D97D513B0159FB9E4A6F3D69C005E82B3'],
|
|
'resave': true,
|
|
'saveUninitialized': true
|
|
|
|
/* 'cookie': {
|
|
'httpOnly': true,
|
|
'secure': true,
|
|
'sameSite': true,
|
|
'maxAge': 2419200000 // Time is in miliseconds
|
|
}*/
|
|
}));
|
|
|
|
app.set('trust proxy', 1);
|
|
|
|
app.get('/', (request, response) => {
|
|
if (request.session.auth)
|
|
response.sendFile(path.join(`${__dirname}/dist/index.html`));
|
|
else
|
|
response.sendFile(path.join(`${__dirname}/security/login.html`));
|
|
});
|
|
|
|
app.use(express.static(path.join(__dirname, sitePath)));
|
|
|
|
// parse requests of content-type - application/x-www-form-urlencoded
|
|
app.use(bodyParser.urlencoded({ 'extended': true }));
|
|
|
|
// parse requests of content-type - application/json
|
|
app.use(bodyParser.json());
|
|
|
|
app.post('/auth', auth.auth);
|
|
|
|
require('./routes/jobs.route')(app);
|
|
require('./routes/jobs.v2.route')(app);
|
|
require('./routes/apply.v2.route')(app);
|
|
require('./routes/vote.route')(app);
|
|
|
|
app.listen(serverPort, () => {
|
|
console.log(`Server is listening on port ${serverPort}`);
|
|
});
|
|
|
|
((() => {
|
|
console.log('Job Server started');
|
|
// doJob();
|
|
})());
|