@ms-cloudpack/app-server 0.1.13 → 0.1.14
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/lib/inlineScripts/getInlineScripts.d.ts.map +1 -1
- package/lib/inlineScripts/getInlineScripts.js +3 -12
- package/lib/inlineScripts/getInlineScripts.js.map +1 -1
- package/lib/startAppServer.d.ts +5 -1
- package/lib/startAppServer.d.ts.map +1 -1
- package/lib/startAppServer.js +16 -14
- package/lib/startAppServer.js.map +1 -1
- package/package.json +10 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInlineScripts.d.ts","sourceRoot":"","sources":["../../src/inlineScripts/getInlineScripts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getInlineScripts.d.ts","sourceRoot":"","sources":["../../src/inlineScripts/getInlineScripts.ts"],"names":[],"mappings":"AAKA,wBAAsB,gBAAgB,sBAOrC"}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
+
import { globSourceFiles } from '@ms-cloudpack/path-utilities';
|
|
1
2
|
import fsPromises from 'fs/promises';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
|
-
const currentFile = fileURLToPath(import.meta.url);
|
|
5
|
-
const currentPath = path.dirname(currentFile);
|
|
6
|
-
/**
|
|
7
|
-
* Correct file extension (`.js` or `.ts`) depending on the context the code is running in:
|
|
8
|
-
* compiled (`.js`) or Jest test in this package (`.ts`).
|
|
9
|
-
*/
|
|
10
|
-
const dynamicImportExtension = path.extname(currentFile);
|
|
11
3
|
let inlineScripts;
|
|
12
|
-
// List of files that we will load on demand.
|
|
13
|
-
const inlineScriptFiles = ['defineProcess', 'errorHandler', 'getBrowserCacheRatio', 'getPageLoadTime'].map((file) => `${file}.inline${dynamicImportExtension}`);
|
|
14
4
|
export async function getInlineScripts() {
|
|
15
5
|
if (!inlineScripts) {
|
|
16
|
-
|
|
6
|
+
const inlineScriptFiles = await globSourceFiles(import.meta.url, '*.inline');
|
|
7
|
+
inlineScripts = await Promise.all(inlineScriptFiles.map((filename) => fsPromises.readFile(filename, 'utf-8')));
|
|
17
8
|
}
|
|
18
9
|
return inlineScripts;
|
|
19
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getInlineScripts.js","sourceRoot":"","sources":["../../src/inlineScripts/getInlineScripts.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"getInlineScripts.js","sourceRoot":"","sources":["../../src/inlineScripts/getInlineScripts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,UAAU,MAAM,aAAa,CAAC;AAErC,IAAI,aAAmC,CAAC;AAExC,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,iBAAiB,GAAG,MAAM,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC7E,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACjH,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["import { globSourceFiles } from '@ms-cloudpack/path-utilities';\nimport fsPromises from 'fs/promises';\n\nlet inlineScripts: string[] | undefined;\n\nexport async function getInlineScripts() {\n if (!inlineScripts) {\n const inlineScriptFiles = await globSourceFiles(import.meta.url, '*.inline');\n inlineScripts = await Promise.all(inlineScriptFiles.map((filename) => fsPromises.readFile(filename, 'utf-8')));\n }\n\n return inlineScripts;\n}\n"]}
|
package/lib/startAppServer.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import type { BundleServer } from '@ms-cloudpack/bundle-server';
|
|
2
3
|
import type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';
|
|
3
4
|
import { type TaskReporter } from '@ms-cloudpack/task-reporter';
|
|
@@ -5,6 +6,7 @@ import type { CloudpackConfig, PackageJson } from '@ms-cloudpack/config-types';
|
|
|
5
6
|
import type { ApiServer, Session } from '@ms-cloudpack/api-server';
|
|
6
7
|
import type { PackageImportPaths } from '@ms-cloudpack/package-utilities';
|
|
7
8
|
import type { PackageHashes } from '@ms-cloudpack/package-hashes';
|
|
9
|
+
import type { Server } from 'http';
|
|
8
10
|
import type { AppServer } from './types/AppServer.js';
|
|
9
11
|
/**
|
|
10
12
|
* The app server hosts the appropriate routes for the web app, primarily returning html content
|
|
@@ -14,7 +16,7 @@ import type { AppServer } from './types/AppServer.js';
|
|
|
14
16
|
* can support whichever routes the app needs, while the bundle server can provide package
|
|
15
17
|
* assets in various forms using its own routing.
|
|
16
18
|
*/
|
|
17
|
-
export declare function startAppServer({ session, bundleServer, apiServer, definition, config, packages, packageImportPaths, reporter, packageHashes, }: {
|
|
19
|
+
export declare function startAppServer({ session, bundleServer, apiServer, definition, config, packages, packageImportPaths, reporter, packageHashes, middlewareMode, server, }: {
|
|
18
20
|
session: Session;
|
|
19
21
|
definition: PackageJson;
|
|
20
22
|
bundleServer: BundleServer;
|
|
@@ -24,5 +26,7 @@ export declare function startAppServer({ session, bundleServer, apiServer, defin
|
|
|
24
26
|
packageImportPaths: PackageImportPaths;
|
|
25
27
|
reporter: TaskReporter;
|
|
26
28
|
packageHashes: PackageHashes;
|
|
29
|
+
middlewareMode?: boolean;
|
|
30
|
+
server?: Server;
|
|
27
31
|
}): Promise<AppServer>;
|
|
28
32
|
//# sourceMappingURL=startAppServer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startAppServer.d.ts","sourceRoot":"","sources":["../src/startAppServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE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B,CAAC;AAEtD;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,EACnC,OAAO,EACP,YAAY,EACZ,SAAS,EACT,UAAU,EACV,MAA8B,EAC9B,QAAQ,EACR,kBAAkB,EAClB,QAAQ,EACR,aAAa,EACb,cAAc,EACd,MAAM,GACP,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,WAAW,CAAC;IACxB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,EAAE,uBAAuB,CAAC;IAClC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,EAAE,YAAY,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,SAAS,CAAC,CAkDrB"}
|
package/lib/startAppServer.js
CHANGED
|
@@ -10,7 +10,7 @@ import { cyan } from '@ms-cloudpack/task-reporter';
|
|
|
10
10
|
* can support whichever routes the app needs, while the bundle server can provide package
|
|
11
11
|
* assets in various forms using its own routing.
|
|
12
12
|
*/
|
|
13
|
-
export async function startAppServer({ session, bundleServer, apiServer, definition, config = {}, packages, packageImportPaths, reporter, packageHashes, }) {
|
|
13
|
+
export async function startAppServer({ session, bundleServer, apiServer, definition, config = {}, packages, packageImportPaths, reporter, packageHashes, middlewareMode, server, }) {
|
|
14
14
|
const { devServer = {} } = config || {};
|
|
15
15
|
// Read the port from the config file or default to array of ports.
|
|
16
16
|
const requireSpecifiedPort = devServer?.port !== undefined;
|
|
@@ -20,24 +20,26 @@ export async function startAppServer({ session, bundleServer, apiServer, definit
|
|
|
20
20
|
// const publicDir = path.resolve(devServer.publicPath ?? 'public');
|
|
21
21
|
const task = reporter.addTask(`Starting app server for "${definition.name}"`);
|
|
22
22
|
try {
|
|
23
|
-
const { close, port, url } = await createExpressApp({
|
|
23
|
+
const { app, close, port, url } = await createExpressApp({
|
|
24
24
|
portRange: ports,
|
|
25
25
|
requireSpecifiedPort,
|
|
26
26
|
hostname: devServer?.domain,
|
|
27
27
|
sslOptions: config.devServer?.https,
|
|
28
28
|
// publicDir,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
middlewareMode,
|
|
30
|
+
server,
|
|
31
|
+
});
|
|
32
|
+
createRoutes({
|
|
33
|
+
app,
|
|
34
|
+
url,
|
|
35
|
+
session,
|
|
36
|
+
definition,
|
|
37
|
+
bundleServer,
|
|
38
|
+
apiServer,
|
|
39
|
+
config,
|
|
40
|
+
packages,
|
|
41
|
+
packageImportPaths,
|
|
42
|
+
packageHashes,
|
|
41
43
|
});
|
|
42
44
|
task.complete({ message: `Available @ ${cyan(url)}`, forceShow: true });
|
|
43
45
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../src/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAqB,IAAI,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"startAppServer.js","sourceRoot":"","sources":["../src/startAppServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAGpE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAqB,IAAI,EAAE,MAAM,6B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SACJ,CAAC;IACJ,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,IAAI,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,4BAA4B,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1F,qBAAqB,CAAC,GAAG,EAAE,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAEvD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC","sourcesContent":["import { createExpressApp } from '@ms-cloudpack/create-express-app';\nimport type { BundleServer } from '@ms-cloudpack/bundle-server';\nimport type { PackageDefinitionsCache } from '@ms-cloudpack/bundler-types';\nimport { createRoutes } from './createRoutes.js';\nimport { exitIfPortUnavailable } from './exitIfPortUnavailable.js';\nimport { type TaskReporter, cyan } from '@ms-cloudpack/task-reporter';\nimport type { CloudpackConfig, PackageJson } from '@ms-cloudpack/config-types';\nimport type { ApiServer, Session } from '@ms-cloudpack/api-server';\nimport type { PackageImportPaths } from '@ms-cloudpack/package-utilities';\nimport type { PackageHashes } from '@ms-cloudpack/package-hashes';\nimport type { Server } from 'http';\nimport type { AppServer } from './types/AppServer.js';\n\n/**\n * The app server hosts the appropriate routes for the web app, primarily returning html content\n * which loads resources from the bundle server.\n *\n * Separating the app server from the bundle service keeps the routes separate - the app server\n * can support whichever routes the app needs, while the bundle server can provide package\n * assets in various forms using its own routing.\n */\nexport async function startAppServer({\n session,\n bundleServer,\n apiServer,\n definition,\n config = {} as CloudpackConfig,\n packages,\n packageImportPaths,\n reporter,\n packageHashes,\n middlewareMode,\n server,\n}: {\n session: Session;\n definition: PackageJson;\n bundleServer: BundleServer;\n apiServer: ApiServer;\n config: CloudpackConfig;\n packages: PackageDefinitionsCache;\n packageImportPaths: PackageImportPaths;\n reporter: TaskReporter;\n packageHashes: PackageHashes;\n middlewareMode?: boolean;\n server?: Server;\n}): Promise<AppServer> {\n const { devServer = {} } = config || ({} as CloudpackConfig);\n\n // Read the port from the config file or default to array of ports.\n const requireSpecifiedPort = devServer?.port !== undefined;\n const ports = devServer?.port ?? [5000, 5001, 5002, 5003];\n\n // Directory to serve as plain static assets. Defaults to \"public\".\n // Can be overridden by setting the 'publicDir' option in the cloudpack config.\n // const publicDir = path.resolve(devServer.publicPath ?? 'public');\n\n const task = reporter.addTask(`Starting app server for \"${definition.name}\"`);\n\n try {\n const { app, close, port, url } = await createExpressApp({\n portRange: ports,\n requireSpecifiedPort,\n hostname: devServer?.domain,\n sslOptions: config.devServer?.https,\n // publicDir,\n middlewareMode,\n server,\n });\n\n createRoutes({\n app,\n url,\n session,\n definition,\n bundleServer,\n apiServer,\n config,\n packages,\n packageImportPaths,\n packageHashes,\n });\n\n task.complete({ message: `Available @ ${cyan(url)}`, forceShow: true });\n\n return {\n close,\n port,\n url,\n };\n } catch (err: unknown) {\n task.complete({ status: 'fail', message: 'Failed to start app server', forceShow: true });\n exitIfPortUnavailable(err, session.projectName, ports);\n\n throw err;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/app-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "An implementation of the App server for Cloudpack.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -14,15 +14,16 @@
|
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@ms-cloudpack/api-server": "^0.29.
|
|
18
|
-
"@ms-cloudpack/bundle-server": "^0.2.
|
|
19
|
-
"@ms-cloudpack/bundler-types": "^0.23.
|
|
20
|
-
"@ms-cloudpack/config-types": "^0.4.
|
|
21
|
-
"@ms-cloudpack/create-express-app": "^1.
|
|
22
|
-
"@ms-cloudpack/overlay": "^0.16.
|
|
23
|
-
"@ms-cloudpack/package-hashes": "^0.3.
|
|
24
|
-
"@ms-cloudpack/package-utilities": "^5.
|
|
17
|
+
"@ms-cloudpack/api-server": "^0.29.18",
|
|
18
|
+
"@ms-cloudpack/bundle-server": "^0.2.11",
|
|
19
|
+
"@ms-cloudpack/bundler-types": "^0.23.12",
|
|
20
|
+
"@ms-cloudpack/config-types": "^0.4.3",
|
|
21
|
+
"@ms-cloudpack/create-express-app": "^1.4.0",
|
|
22
|
+
"@ms-cloudpack/overlay": "^0.16.60",
|
|
23
|
+
"@ms-cloudpack/package-hashes": "^0.3.14",
|
|
24
|
+
"@ms-cloudpack/package-utilities": "^5.8.0",
|
|
25
25
|
"@ms-cloudpack/path-string-parsing": "^1.1.3",
|
|
26
|
+
"@ms-cloudpack/path-utilities": "^2.5.0",
|
|
26
27
|
"@ms-cloudpack/task-reporter": "^0.11.1",
|
|
27
28
|
"jsdom": "^22.0.0"
|
|
28
29
|
},
|