taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 5208df82d61091bb5492b215d2acf842e89fc048
parent 8ed362d08297c0622e8da5429dd936e2c5d2d08a
Author: Sebastian <sebasjm@gmail.com>
Date:   Fri,  5 Jan 2024 09:52:56 -0300

make tls optional

Diffstat:
Mpackages/web-util/src/serve.ts | 18+++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/packages/web-util/src/serve.ts b/packages/web-util/src/serve.ts @@ -29,6 +29,7 @@ export async function serve(opts: { folder: string; port: number; source?: string; + tls?: boolean; examplesLocationJs?: string; examplesLocationCss?: string; onSourceUpdate?: () => Promise<void>; @@ -39,9 +40,14 @@ export async function serve(opts: { const httpServer = http.createServer(app); const httpPort = opts.port; - const httpsServer = https.createServer(httpServerOptions, app); - const httpsPort = opts.port + 1; - const servers = [httpServer, httpsServer]; + let httpsServer: typeof httpServer | undefined; + let httpsPort: number | undefined; + const servers = [httpServer]; + if (opts.tls) { + httpsServer = https.createServer(httpServerOptions, app); + httpsPort = opts.port + 1; + servers.push(httpsServer) + } logger.info(`Dev server. Endpoints:`); logger.info(` ${PATHS.APP}: where root application can be tested`); @@ -120,6 +126,8 @@ export async function serve(opts: { logger.info(`Serving ${opts.folder} on ${httpPort}: plain HTTP`); httpServer.listen(httpPort); - logger.info(`Serving ${opts.folder} on ${httpsPort}: HTTP + TLS`); - httpsServer.listen(httpsPort); + if (httpsServer !== undefined) { + logger.info(`Serving ${opts.folder} on ${httpsPort}: HTTP + TLS`); + httpsServer.listen(httpsPort); + } }