added ssl
This commit is contained in:
parent
4f837cc325
commit
476e69fe1b
1 changed files with 14 additions and 3 deletions
17
api.js
17
api.js
|
@ -1,12 +1,23 @@
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
const https = require('https');
|
||||||
const app = express();
|
const app = express();
|
||||||
const PORT = 3000;
|
const os = require('os');
|
||||||
|
const PORT = 7722;
|
||||||
|
|
||||||
const data = fs.readFileSync('db/PS2_LIST.txt', 'utf-8');
|
const data = fs.readFileSync('db/PS2_LIST.txt', 'utf-8');
|
||||||
const gameMap = {};
|
const gameMap = {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const sslOptions = {
|
||||||
|
key: fs.readFileSync(path.join(os.homedir(), 'certs', 'privkey.pem')),
|
||||||
|
cert: fs.readFileSync(path.join(os.homedir(), 'certs', 'cert.pem')),
|
||||||
|
ca: fs.readFileSync(path.join(os.homedir(), 'certs', 'fullchain.pem'))
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
data.split('\n').forEach(line => {
|
data.split('\n').forEach(line => {
|
||||||
const match = line.match(/^(\S+)\s+(.*)$/);
|
const match = line.match(/^(\S+)\s+(.*)$/);
|
||||||
if (match) {
|
if (match) {
|
||||||
|
@ -44,6 +55,6 @@ app.get('/contact', (req, res) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.listen(PORT, () => {
|
https.createServer(sslOptions, app).listen(PORT, () => {
|
||||||
console.log(`Server running at http://localhost:${PORT}`);
|
console.log(`Server running at https://localhost:${PORT}`);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue