@ms-cloudpack/create-express-app 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +31 -1
- package/CHANGELOG.md +18 -2
- package/lib/createExpressApp.d.ts +1 -0
- package/lib/createExpressApp.js +9 -2
- package/lib/createExpressApp.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,37 @@
|
|
|
2
2
|
"name": "@ms-cloudpack/create-express-app",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Tue,
|
|
5
|
+
"date": "Tue, 29 Nov 2022 08:10:18 GMT",
|
|
6
|
+
"tag": "@ms-cloudpack/create-express-app_v1.1.2",
|
|
7
|
+
"version": "1.1.2",
|
|
8
|
+
"comments": {
|
|
9
|
+
"patch": [
|
|
10
|
+
{
|
|
11
|
+
"author": "dake.3601@gmail.com",
|
|
12
|
+
"package": "@ms-cloudpack/create-express-app",
|
|
13
|
+
"commit": "4ea7bd17f870a65b0b6df7c5d1893ac0115ad527",
|
|
14
|
+
"comment": "Disabling directory indexing."
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"date": "Wed, 23 Nov 2022 08:10:05 GMT",
|
|
21
|
+
"tag": "@ms-cloudpack/create-express-app_v1.1.1",
|
|
22
|
+
"version": "1.1.1",
|
|
23
|
+
"comments": {
|
|
24
|
+
"patch": [
|
|
25
|
+
{
|
|
26
|
+
"author": "dake.3601@gmail.com",
|
|
27
|
+
"package": "@ms-cloudpack/create-express-app",
|
|
28
|
+
"commit": "d24cd9f25c708b1e3c02f5ba705e3610fb3e54c2",
|
|
29
|
+
"comment": "If port range is specified, throw error if none is available."
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"date": "Tue, 22 Nov 2022 08:10:22 GMT",
|
|
6
36
|
"tag": "@ms-cloudpack/create-express-app_v1.1.0",
|
|
7
37
|
"version": "1.1.0",
|
|
8
38
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
# Change Log - @ms-cloudpack/create-express-app
|
|
2
2
|
|
|
3
|
-
This log was last generated on Tue,
|
|
3
|
+
This log was last generated on Tue, 29 Nov 2022 08:10:18 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## 1.1.2
|
|
8
|
+
|
|
9
|
+
Tue, 29 Nov 2022 08:10:18 GMT
|
|
10
|
+
|
|
11
|
+
### Patches
|
|
12
|
+
|
|
13
|
+
- Disabling directory indexing. (dake.3601@gmail.com)
|
|
14
|
+
|
|
15
|
+
## 1.1.1
|
|
16
|
+
|
|
17
|
+
Wed, 23 Nov 2022 08:10:05 GMT
|
|
18
|
+
|
|
19
|
+
### Patches
|
|
20
|
+
|
|
21
|
+
- If port range is specified, throw error if none is available. (dake.3601@gmail.com)
|
|
22
|
+
|
|
7
23
|
## 1.1.0
|
|
8
24
|
|
|
9
|
-
Tue, 22 Nov 2022 08:10:
|
|
25
|
+
Tue, 22 Nov 2022 08:10:22 GMT
|
|
10
26
|
|
|
11
27
|
### Minor changes
|
|
12
28
|
|
|
@@ -4,6 +4,7 @@ import type { Server } from 'http';
|
|
|
4
4
|
import type { HttpsConfig } from './parseHttpsConfig.js';
|
|
5
5
|
export declare function createExpressApp(options: {
|
|
6
6
|
portRange?: number | number[];
|
|
7
|
+
requireSpecifiedPort?: boolean;
|
|
7
8
|
hostname?: string;
|
|
8
9
|
sslOptions?: HttpsConfig;
|
|
9
10
|
setupCallback?: (app: Express) => void;
|
package/lib/createExpressApp.js
CHANGED
|
@@ -4,18 +4,25 @@ import cors from 'cors';
|
|
|
4
4
|
import compression from 'compression';
|
|
5
5
|
import getPort from 'get-port';
|
|
6
6
|
export async function createExpressApp(options) {
|
|
7
|
-
const { setupCallback, hostname, sslOptions,
|
|
7
|
+
const { setupCallback, hostname, sslOptions, requireSpecifiedPort, publicDir, portRange: ports } = options;
|
|
8
|
+
const portRange = typeof ports === 'number' ? [ports] : ports;
|
|
9
|
+
if (requireSpecifiedPort && (portRange === undefined || portRange.length === 0)) {
|
|
10
|
+
throw new Error('No port specified');
|
|
11
|
+
}
|
|
8
12
|
// Get the available port.
|
|
9
13
|
const port = await getPort({
|
|
10
14
|
port: portRange,
|
|
11
15
|
});
|
|
16
|
+
if (requireSpecifiedPort && portRange && !portRange.includes(port)) {
|
|
17
|
+
throw new Error('Specified port not available');
|
|
18
|
+
}
|
|
12
19
|
const app = express();
|
|
13
20
|
// Use cors.
|
|
14
21
|
app.use(cors());
|
|
15
22
|
// Use compression.
|
|
16
23
|
app.use(compression());
|
|
17
24
|
if (publicDir !== undefined) {
|
|
18
|
-
app.use(express.static(publicDir));
|
|
25
|
+
app.use(express.static(publicDir, { index: false }));
|
|
19
26
|
}
|
|
20
27
|
// Call setup callback with the app.
|
|
21
28
|
setupCallback?.(app);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createExpressApp.js","sourceRoot":"","sources":["../src/createExpressApp.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAgB,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,OAAO,MAAM,UAAU,CAAC;AAI/B,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"createExpressApp.js","sourceRoot":"","sources":["../src/createExpressApp.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAgB,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;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