1401 Enable SSL server

This commit is contained in:
Stanislav Ratashnyuk 2025-11-17 23:22:30 +00:00
parent 56de415db0
commit e22d31e6ee
2 changed files with 28 additions and 2 deletions

View File

@ -1,10 +1,10 @@
import express from 'express';
import http from 'http';
import getPort from 'get-port';
import socketClusterServer from 'socketcluster-server';
import getOptions from './options.js';
import routes from './routes.js';
import createStore from './store.js';
import { createServer } from './utils/create-server.js';
// const LOG_LEVEL_NONE = 0;
// const LOG_LEVEL_ERROR = 1;
@ -37,7 +37,8 @@ export default async function (argv: { [arg: string]: any }): Promise<{
console.log('[ReduxDevTools] Start server...');
console.log('-'.repeat(80) + '\n');
}
const httpServer = http.createServer();
const httpServer = createServer(argv);
const agServer = socketClusterServer.attach(httpServer, options);
const app = express();

View File

@ -0,0 +1,25 @@
import http from 'http';
import https from 'https';
export const createServer = (argv: { [arg: string]: unknown }): http.Server | https.Server => {
const typedArgv = argv as {
protocol: string;
key: string;
cert: string;
};
let result;
if (typedArgv.protocol === 'https') {
const options = {
key: typedArgv.key,
cert: typedArgv.cert,
};
result = https.createServer(options);
} else {
result = http.createServer();
}
return result;
}