|
|
@ -17,7 +17,7 @@ const distDir = path.join(__dirname, 'client'); |
|
|
|
const trim = (str: string): string => str.replace(/\/*$/, ''); |
|
|
|
|
|
|
|
export default function createServer( |
|
|
|
{ base, port, host, title }: Server, |
|
|
|
{ base, port, host, title, disableHelmet }: Server, |
|
|
|
{ key, cert }: SSLBuffer |
|
|
|
): SocketIO.Server { |
|
|
|
const basePath = trim(base); |
|
|
@ -61,7 +61,6 @@ export default function createServer( |
|
|
|
const app = express(); |
|
|
|
app |
|
|
|
.use(morgan('combined', { stream: logger.stream })) |
|
|
|
.use(helmet()) |
|
|
|
.use(compression()) |
|
|
|
.use(favicon(path.join(distDir, 'favicon.ico'))) |
|
|
|
.use(`${basePath}/public`, express.static(distDir)) |
|
|
@ -77,6 +76,10 @@ export default function createServer( |
|
|
|
.get(basePath, html) |
|
|
|
.get(`${basePath}/ssh/:user`, html); |
|
|
|
|
|
|
|
if (!disableHelmet) { |
|
|
|
app.use(helmet()); |
|
|
|
} |
|
|
|
|
|
|
|
return socket( |
|
|
|
!isUndefined(key) && !isUndefined(cert) |
|
|
|
? https.createServer({ key, cert }, app).listen(port, host, () => { |
|
|
|