-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
58 lines (42 loc) · 1.41 KB
/
index.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
const debug = require("debug")("app:startup");
//const dbDebugger = require("debug")("app:db");
const config = require("config")
const express = require("express");
const logger = require("./middleware/logger")
const app = express();
const Joi = require("joi");
const helmet = require("helmet")
const morgan = require("morgan")
const courses = require('./routes/courses')
const home = require('./routes/home')
app.set('view engine', 'pug')
app.set('views', './views')//default
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(express.static("public"))
app.use(helmet());
app.use("/api/courses", courses);
app.use('/', home)
if (app.get("env") === "development") {
app.use(morgan("tiny"))
debug("morgan enabled")
}
//Db work
//dbDebugger("db enabled")
//console.log(`Environment:${process.env.NODE_ENV}`)
//console.log(`App:${app.get("env")}`)
console.log("Application name" + config.get("name"))
console.log("Mail Server name" + config.get("mail-server"))
console.log("Mail password" + config.get("mail.password"))
app.use(logger);
app.use(function (req, res, next) {
console.log("Authenticating")
next();
})
app.get("/", (req, res) => {
res.render('index', { title: "App", message: "Hello" })
// res.status(200).send("Node Server running !!!");
});
const port = process.env.PORT || 3000;
app.listen(port, () => console.log(`Listening on Port ${port}`))
module.exports = app;