Skip to content

Commit 86b8f47

Browse files
committed
add integration tests, extract selectCompressedFile
1 parent 0ed7f36 commit 86b8f47

File tree

14 files changed

+333
-414
lines changed

14 files changed

+333
-414
lines changed

src/core/server/core_app/bundle_routes/bundles_route.test.ts

Lines changed: 0 additions & 296 deletions
This file was deleted.

src/core/server/core_app/bundle_routes/bundles_route.ts

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,72 +6,12 @@
66
* Side Public License, v 1.
77
*/
88

9-
import { join } from 'path';
10-
11-
import * as UiSharedDeps from '@kbn/ui-shared-deps';
129
import { schema } from '@kbn/config-schema';
13-
import { PackageInfo } from '@kbn/config';
14-
15-
import { fromRoot } from '../../utils';
1610
import { IRouter } from '../../http';
17-
import { UiPlugins } from '../../plugins';
1811
import { createDynamicAssetHandler } from './dynamic_asset_response';
1912
import { FileHashCache } from './file_hash_cache';
2013

21-
/**
22-
* Creates the routes that serves files from `bundlesPath`.
23-
*
24-
* @param {Object} options
25-
* @property {Array<{id,path}>} options.npUiPluginPublicDirs array of ids and paths that should be served for new platform plugins
26-
* @property {string} options.regularBundlesPath
27-
* @property {string} options.basePublicPath
28-
*
29-
* @return Array.of({Hapi.Route})
30-
*/
31-
export function registerBundleRoutes({
32-
router,
33-
serverBasePath, // serverBasePath
34-
uiPlugins,
35-
packageInfo,
36-
}: {
37-
router: IRouter;
38-
serverBasePath: string;
39-
uiPlugins: UiPlugins;
40-
packageInfo: PackageInfo;
41-
}) {
42-
const { dist: isDist, buildNum } = packageInfo;
43-
// rather than calculate the fileHash on every request, we
44-
// provide a cache object to `resolveDynamicAssetResponse()` that
45-
// will store the 100 most recently used hashes.
46-
const fileHashCache = new FileHashCache();
47-
48-
registerRouteForBundle(router, {
49-
publicPath: `${serverBasePath}/${buildNum}/bundles/kbn-ui-shared-deps/`,
50-
routePath: `/${buildNum}/bundles/kbn-ui-shared-deps/`,
51-
bundlesPath: UiSharedDeps.distDir,
52-
fileHashCache,
53-
isDist,
54-
});
55-
registerRouteForBundle(router, {
56-
publicPath: `${serverBasePath}/${buildNum}/bundles/core/`,
57-
routePath: `/${buildNum}/bundles/core/`,
58-
bundlesPath: fromRoot(join('src', 'core', 'target', 'public')),
59-
fileHashCache,
60-
isDist,
61-
});
62-
63-
[...uiPlugins.internal.entries()].forEach(([id, { publicTargetDir }]) => {
64-
registerRouteForBundle(router, {
65-
publicPath: `${serverBasePath}/${buildNum}/bundles/plugin/${id}/`,
66-
routePath: `/${buildNum}/bundles/plugin/${id}/`,
67-
bundlesPath: publicTargetDir,
68-
fileHashCache,
69-
isDist,
70-
});
71-
});
72-
}
73-
74-
function registerRouteForBundle(
14+
export function registerRouteForBundle(
7515
router: IRouter,
7616
{
7717
publicPath,

0 commit comments

Comments
 (0)