diff --git a/api.js b/api.js index ff14ec0..b323216 100644 --- a/api.js +++ b/api.js @@ -1,12 +1,23 @@ const express = require('express'); const fs = require('fs'); const path = require('path'); +const https = require('https'); const app = express(); -const PORT = 3000; +const os = require('os'); +const PORT = 7722; const data = fs.readFileSync('db/PS2_LIST.txt', 'utf-8'); 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 => { const match = line.match(/^(\S+)\s+(.*)$/); if (match) { @@ -44,6 +55,6 @@ app.get('/contact', (req, res) => { }); -app.listen(PORT, () => { - console.log(`Server running at http://localhost:${PORT}`); +https.createServer(sslOptions, app).listen(PORT, () => { + console.log(`Server running at https://localhost:${PORT}`); });