summaryrefslogtreecommitdiff
path: root/app.js
blob: 00fabf17e4f61c9b250450e5d70ac3ee22383fd8 (plain)
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
"use strict";

// handling imports
const bodyParser = require('body-parser');
const express = require('express');
const path = require('path');
var config = require('./server/js/config');

// handling variables
const app = express();
const configPath = config.defaultConfigPath;
config.loadConfig(configPath);
const PORT = module.exports.PORT = config.loadedConfig.settings.port || process.env.PORT || 3000;

// loading configurations
app.use(express.static(path.join(__dirname, '/public')));
app.use(bodyParser.urlencoded({extended: true}));

// set the view engine to ejs
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, '/views'));

// routes management
const home = require("./routes/home");
const info = require("./routes/info");
const search = require("./routes/search");
const visit = require("./routes/visit");
const {save, settings} = require("./routes/settings");

app.get('/', home);
app.get('/info', info);
app.get('/visit', visit);
app.get('/settings', settings);
app.post('/settings', save);
app.post('/search', search);

// app start
app.listen(PORT, () => console.log("Server running on port " + PORT));