forked from c9/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.js
More file actions
37 lines (26 loc) · 836 Bytes
/
Copy pathstatic.js
File metadata and controls
37 lines (26 loc) · 836 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
29
30
31
32
33
34
35
36
37
var selfsigned = require('selfsigned'); //require('selfsigned');
var port = process.env.PORT || 8383;
var https = require('https');
var http = require('http');
var express = require('express');
// var Gun = require('gun');
// require('gun/axe');
var app = express();
app.use(express.static(__dirname + "/"));
// app.use(Gun.serve);
var server;
if (selfsigned){
var attrs = null; //[{ name: 'commonName', value: '127.0.0.' }];
var pems = selfsigned.generate(attrs, { days: 365 });
// we will pass our 'app' to 'https' server
server = https.createServer({
key: pems.private,
cert: pems.cert
}, app)
.listen(port);
}else{
server = http.createServer(app)
.listen(port);
}
// var gun = Gun({ file: 'data', web: server });
console.log('Server started on port ' + port + '');