Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
add: useSSL args
Browse files Browse the repository at this point in the history
  • Loading branch information
abbddkr committed Jan 2, 2021
1 parent e8a60d2 commit 83dd376
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const bodyParser = require('body-parser');
const sqlite3 = require('sqlite3').verbose();
const jwt = require('jsonwebtoken');
const https = require('https');
const http = require('http');
const cors = require('cors');
const dotenv = require("dotenv");
const fs = require('fs');
Expand Down Expand Up @@ -169,10 +170,18 @@ server.use('/upload', upload);

server.get('*', (req, res) => res.sendFile(__dirname + '/public/index.html'));

https.createServer({
cert: fs.readFileSync(process.env.CERT_PATH),
ca: fs.readFileSync(process.env.CHAIN_PATH),
key: fs.readFileSync(process.env.KEY_PATH)
},server).listen(4000,'0.0.0.0', function () {
console.log('0xsp Started on port 4000');
});
var args = process.argv;

if(args.slice(2) == 'useSSL'){
https.createServer({
cert: fs.readFileSync(process.env.CERT_PATH),
ca: fs.readFileSync(process.env.CHAIN_PATH),
key: fs.readFileSync(process.env.KEY_PATH)
},server).listen(4000,'0.0.0.0', function () {
console.log('0xsp Started on port 4000');
});
}else{
http.createServer(server).listen(4000,'0.0.0.0', function () {
console.log('0xsp Started on port 4000');
});
}

0 comments on commit 83dd376

Please sign in to comment.