forked from mleitejensen/kalender
-
Notifications
You must be signed in to change notification settings - Fork 15
/
app.js
25 lines (22 loc) · 803 Bytes
/
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
require('dotenv').config();
const express = require("express");
const {connectToDB} = require('./handlers/dbhandler');
const app = express();
const routes = require('./routes/defaultroutes');
//Environment variables
const PORT = process.env.PORT || 3000;
const dbname = process.env.DBNAME;
const dbstring = process.env.DBSTRING;
app.set("view engine", "ejs");
app.use(express.static(__dirname + '/public/'));
app.use(express.urlencoded({extended:true}));
app.use(express.json());
app.use(routes);
console.log(process.env.DEBUG == false)
app.listen(PORT, () => {
connectToDB(dbstring, dbname);
console.log(`Server running on port ${PORT}\nopen http://localhost:${PORT} to view the page`);
if(process.env.DEBUG == false) {
console.log('WARNING! CURRENTLY IN DEBUG MODE!');
}
});