Skip to content

Commit e22d31e

Browse files
author
Stanislav Ratashnyuk
committed
1401 Enable SSL server
1 parent 56de415 commit e22d31e

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

packages/redux-devtools-cli/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import express from 'express';
2-
import http from 'http';
32
import getPort from 'get-port';
43
import socketClusterServer from 'socketcluster-server';
54
import getOptions from './options.js';
65
import routes from './routes.js';
76
import createStore from './store.js';
7+
import { createServer } from './utils/create-server.js';
88

99
// const LOG_LEVEL_NONE = 0;
1010
// const LOG_LEVEL_ERROR = 1;
@@ -37,7 +37,8 @@ export default async function (argv: { [arg: string]: any }): Promise<{
3737
console.log('[ReduxDevTools] Start server...');
3838
console.log('-'.repeat(80) + '\n');
3939
}
40-
const httpServer = http.createServer();
40+
41+
const httpServer = createServer(argv);
4142
const agServer = socketClusterServer.attach(httpServer, options);
4243

4344
const app = express();
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import http from 'http';
2+
import https from 'https';
3+
4+
export const createServer = (argv: { [arg: string]: unknown }): http.Server | https.Server => {
5+
const typedArgv = argv as {
6+
protocol: string;
7+
key: string;
8+
cert: string;
9+
};
10+
11+
let result;
12+
13+
if (typedArgv.protocol === 'https') {
14+
const options = {
15+
key: typedArgv.key,
16+
cert: typedArgv.cert,
17+
};
18+
19+
result = https.createServer(options);
20+
} else {
21+
result = http.createServer();
22+
}
23+
24+
return result;
25+
}

0 commit comments

Comments
 (0)