Skip to content

Commit 9484aea

Browse files
Miel Vander SandeRubenVerborgh
Miel Vander Sande
authored andcommitted
Added defaults
1 parent 4f93e8a commit 9484aea

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

config/config-defaults.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"title": "Linked Data Fragments server",
33
"baseURL": "/",
4+
"protocol": "http",
45

56
"port": 3000,
67
"workers": 1,
@@ -47,5 +48,13 @@
4748
]
4849
},
4950

51+
"ssl": {
52+
"keys" : {
53+
"key": "localhost.key'",
54+
"ca": [],
55+
"cert": "localhost.crt.pem"
56+
},
57+
},
58+
5059
"logging": { "enabled": false, "file": "access.log" }
5160
}

lib/LinkedDataFragmentsServer.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,23 @@ var _ = require('lodash'),
1010
// Creates a new LinkedDataFragmentsServer
1111
function LinkedDataFragmentsServer(options) {
1212
// Create the HTTP(S) server
13-
var server, sockets = 0,
14-
protocol = options.protocol || 'http';
13+
var server, sockets = 0;
1514

16-
switch (protocol) {
15+
switch (options.protocol) {
1716
case 'https':
18-
var ssl = options.ssl || {};
19-
_.assign(ssl,
20-
_.mapValues(_.defaults(ssl.keys || {}, {
21-
key: path.join(__dirname, '../localhost.key'),
22-
cert: path.join(__dirname, '../localhost.crt'),
23-
}),
17+
var ssl = _.assign(options.ssl || {},
18+
_.mapValues(ssl.keys || {},
2419
function (v) {
2520
return _.isArray(v) ? _.map(v, function (w) { return fs.readFileSync(w, 'ascii'); }) : fs.readFileSync(v, 'ascii');
2621
})
27-
);
22+
);
2823

2924
server = require('https').createServer(ssl);
3025
break;
31-
default:
26+
case 'http':
3227
server = require('http').createServer();
28+
default:
29+
throw new Error('The configured protocol ' + options.protocol + ' is invalid.');
3330
}
3431
server._protocol = protocol;
3532

0 commit comments

Comments
 (0)