@ms-cloudpack/create-express-app
Advanced tools
Comparing version 1.7.5 to 1.8.0
@@ -19,3 +19,3 @@ import type { HttpsConfig } from '@ms-cloudpack/common-types'; | ||
/** Options for an HTTPS server. Certificate paths support tokens `{homedir}` and `{tmpdir}`. */ | ||
sslOptions?: HttpsConfig; | ||
sslOptions?: HttpsConfig | true; | ||
/** @deprecated use returned `app` */ | ||
@@ -22,0 +22,0 @@ setupCallback?: (app: Express, baseUrl: string) => void | Promise<void>; |
@@ -42,3 +42,3 @@ import compression from 'compression'; | ||
let server = options.server; | ||
const isHttps = !!sslOptions && Object.keys(sslOptions).length !== 0; | ||
const isHttps = !!sslOptions; | ||
const protocol = isHttps ? 'https' : 'http'; | ||
@@ -54,3 +54,3 @@ let url = `${protocol}://${domain}`; | ||
// Create an HTTPS server. | ||
const httpsServer = https.createServer(parseHttpsConfig(sslOptions, cwd), app); | ||
const httpsServer = https.createServer(await parseHttpsConfig({ domain, https: sslOptions, cwd }), app); | ||
server = httpsServer.listen(port, domain); | ||
@@ -57,0 +57,0 @@ } |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
export declare function getDomain(str: string | undefined): string; | ||
export declare function getDomain(domain?: string | string[]): string; | ||
//# sourceMappingURL=getDomain.d.ts.map |
@@ -12,7 +12,7 @@ import os from 'os'; | ||
*/ | ||
export function getDomain(str) { | ||
if (!str) | ||
export function getDomain(domain) { | ||
const primaryDomain = Array.isArray(domain) ? domain[0] : domain; | ||
if (!primaryDomain) | ||
return 'localhost'; | ||
// Replace the address symbols. | ||
return str.replace(/{(\w+)}/g, (match, symbol) => addressSymbols[symbol]() || match); | ||
return primaryDomain.replace(/{(\w+)}/g, (match, symbol) => addressSymbols[symbol]() || match); | ||
} | ||
@@ -19,0 +19,0 @@ function getLocalIP() { |
import type { HttpsConfig } from '@ms-cloudpack/common-types'; | ||
export declare function parseHttpsConfig(config: HttpsConfig, cwd: string): HttpsConfig; | ||
export declare function parseHttpsConfig(options: { | ||
domain?: string; | ||
https: true | HttpsConfig; | ||
cwd: string; | ||
}): Promise<HttpsConfig>; | ||
//# sourceMappingURL=parseHttpsConfig.d.ts.map |
@@ -5,8 +5,17 @@ import path from 'path'; | ||
import { slash } from '@ms-cloudpack/path-string-parsing'; | ||
import { getCertificate } from '@ms-cloudpack/setup-utilities'; | ||
/* | ||
* Read certificates files in Https Config and return the contents. | ||
*/ | ||
export function parseHttpsConfig(config, cwd) { | ||
export async function parseHttpsConfig(options) { | ||
const { https, cwd } = options; | ||
if (https === true) { | ||
const httpsConfig = await getCertificate(options); | ||
if (!httpsConfig) { | ||
throw new Error(`No certificate found for the domain "${options.domain}". Make sure you have a valid certificate in the cloudpack.config.json file.`); | ||
} | ||
return httpsConfig; | ||
} | ||
const sslOptions = {}; | ||
for (const [key, value] of Object.entries(config)) { | ||
for (const [key, value] of Object.entries(https)) { | ||
// Read the file contents for the certificates. | ||
@@ -13,0 +22,0 @@ if (['ca', 'cert', 'key', 'pfx'].includes(key) && typeof value === 'string') { |
{ | ||
"name": "@ms-cloudpack/create-express-app", | ||
"version": "1.7.5", | ||
"version": "1.8.0", | ||
"description": "Helper for creating an express app server, abstracting a common plugin setup.", | ||
@@ -17,5 +17,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/common-types": "^0.16.1", | ||
"@ms-cloudpack/common-types": "^0.17.0", | ||
"@ms-cloudpack/path-string-parsing": "^1.2.4", | ||
"@ms-cloudpack/path-utilities": "^2.7.34", | ||
"@ms-cloudpack/path-utilities": "^2.7.35", | ||
"@ms-cloudpack/setup-utilities": "^0.1.1", | ||
"@types/express": "^4.17.16", | ||
@@ -22,0 +23,0 @@ "compression": "^1.7.4", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28005
238
9
+ Added@ljharb/through@2.3.13(transitive)
+ Added@ms-cloudpack/common-types@0.17.00.19.7(transitive)
+ Added@ms-cloudpack/setup-utilities@0.1.3(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedhostile@1.4.0(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedsplit@1.0.1(transitive)
+ Addedsupports-color@7.2.0(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedwrappy@1.0.2(transitive)
- Removed@ms-cloudpack/common-types@0.16.1(transitive)