@ms-cloudpack/create-express-app
Advanced tools
Comparing version 1.3.17 to 1.4.0
@@ -12,4 +12,7 @@ /// <reference types="node" resolution-mode="require"/> | ||
publicDir?: string; | ||
middlewareMode?: boolean; | ||
server?: Server; | ||
}): Promise<{ | ||
server: Server; | ||
app: Express; | ||
server: Server | undefined; | ||
close: () => Promise<void>; | ||
@@ -16,0 +19,0 @@ url: string; |
@@ -8,3 +8,3 @@ import express, {} from 'express'; | ||
export async function createExpressApp(options) { | ||
const { setupCallback, hostname, sslOptions, requireSpecifiedPort, publicDir, portRange: ports } = options; | ||
const { setupCallback, hostname, sslOptions, requireSpecifiedPort, publicDir, portRange: ports, middlewareMode, } = options; | ||
const portRange = typeof ports === 'number' ? [ports] : ports; | ||
@@ -30,3 +30,3 @@ if (requireSpecifiedPort && (portRange === undefined || portRange.length === 0)) { | ||
const domain = hostname || 'localhost'; | ||
let server; | ||
let server = options.server; | ||
const protocol = sslOptions && Object.keys(sslOptions).length !== 0 ? 'https' : 'http'; | ||
@@ -39,3 +39,3 @@ let url = `${protocol}://${domain}`; | ||
await setupCallback?.(app, url); | ||
if (sslOptions && Object.keys(sslOptions).length !== 0) { | ||
if (!middlewareMode && sslOptions && Object.keys(sslOptions).length !== 0) { | ||
// Create an HTTPS server. | ||
@@ -45,3 +45,3 @@ const httpsServer = https.createServer(parseHttpsConfig(sslOptions), app); | ||
} | ||
else { | ||
else if (!middlewareMode) { | ||
// Create an HTTP server. | ||
@@ -52,3 +52,3 @@ server = app.listen(port, domain); | ||
const sockets = new Set(); | ||
server.on('connection', (socket) => { | ||
server?.on('connection', (socket) => { | ||
sockets.add(socket); | ||
@@ -60,2 +60,3 @@ socket.on('close', () => { | ||
return { | ||
app, | ||
server, | ||
@@ -67,3 +68,3 @@ async close() { | ||
sockets.clear(); | ||
await new Promise((resolve, reject) => server.close((err) => (err ? reject(err) : resolve()))); | ||
await new Promise((resolve, reject) => server?.close((err) => (err ? reject(err) : resolve()))); | ||
}, | ||
@@ -70,0 +71,0 @@ url, |
import * as express from 'express'; | ||
export type { Express, Request, Response } from 'express'; | ||
export type { Express, Request, Response, Router } from 'express'; | ||
export { createExpressApp } from './createExpressApp.js'; | ||
@@ -4,0 +4,0 @@ export { type HttpsConfig, parseHttpsConfig } from './parseHttpsConfig.js'; |
{ | ||
"name": "@ms-cloudpack/create-express-app", | ||
"version": "1.3.17", | ||
"version": "1.4.0", | ||
"description": "Helper for creating an express app server, abstracting a common plugin setup.", | ||
@@ -17,3 +17,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"@ms-cloudpack/path-utilities": "^2.4.3", | ||
"@ms-cloudpack/path-utilities": "^2.5.0", | ||
"@types/express": "^4.17.16", | ||
@@ -20,0 +20,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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
17942
146
1