-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
67 lines (51 loc) · 1.56 KB
/
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
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
59
60
61
62
63
64
65
66
67
/*jshint globalstrict: true, devel: true, node: true*/
'use strict';
require('dotenv').config();
const nunjucks = require('nunjucks');
var path = require('path');
var express = require('express');
var app = express();
/*
Configure view engine
*/
nunjucks.configure('views', {
express: app,
autoescape: true
});
app.set('view engine', 'njk');
/*
Using body parser in Express v4.16.0 and higher
*/
app.use(express.json());
app.use(express.urlencoded({
extended: true
}));
app.use(express.static(path.join(__dirname, 'public')));
/*
Routing
*/
const job_role_routes = require('./routes/job_role_routes');
app.use("/job-roles",job_role_routes);
const capability_routes = require('./routes/capability_routes');
app.use("/capabilities",capability_routes);
const spec_route = require('./routes/job_spec_routes');
app.use("/job-roles-spec",spec_route);
const band_routes = require('./routes/band_routes');
app.use("/bands-training",band_routes)
const admin_route = require('./routes/admin_routes');
app.use("/admin", admin_route);
app.get("/", (req, res) => res.render('index'));
app.get("*", (req, res) => {
res.render('error', {error: {code: 404, message: "Page not found."}});
res.statusCode = 404;
});
/* Port configuration */
let server = app.listen(process.env.PORT || 7999, function () {
console.log(`Application started on PORT: ${process.env.PORT || 7999}`);
});
/* Handle interrupt to close the application */
process.on('SIGINT', function () {
console.log("Application shutting down...");
process.exit();
});
module.exports = server;