-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (23 loc) · 801 Bytes
/
server.js
File metadata and controls
28 lines (23 loc) · 801 Bytes
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
var config = require('./config/masters');
var express = require('express');
var hbars = require('express-handlebars');
var path = require('path');
var SuperMaster = require('./lib/superMaster.js');
var jenkins = new SuperMaster(config.masters);
var port = process.env.PORT || 8080;
var app = express();
// Configure templating engine
app.engine('handlebars', hbars());
app.set('view engine', 'handlebars');
app.set('views', path.resolve(__dirname, 'public'));
// Static assets
app.use('/', express.static(path.resolve(__dirname, "public")));
// index.html
app.get('/', (req, res) => {
jenkins.getJobs((err, jobs) => {
// Inject list of jobs into page
res.render('index', { jobs: JSON.stringify({ "jobs": jobs }) } );
});
});
app.listen(port);
console.info("Listening on port", port);