@backstage/plugin-app-backend 0.4.6-next.0 → 0.5.0-next.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.md +32 -0
- package/dist/index.d.ts +1 -62
- package/dist/service/router.cjs.js +6 -4
- package/dist/service/router.cjs.js.map +1 -1
- package/package.json +11 -28
- package/dist/alpha.cjs.js +0 -10
- package/dist/alpha.cjs.js.map +0 -1
- package/dist/alpha.d.ts +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @backstage/plugin-app-backend
|
|
2
2
|
|
|
3
|
+
## 0.5.0-next.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- @backstage/config-loader@1.10.0-next.0
|
|
9
|
+
- @backstage/backend-plugin-api@1.2.1-next.1
|
|
10
|
+
- @backstage/config@1.3.2
|
|
11
|
+
- @backstage/errors@1.2.7
|
|
12
|
+
- @backstage/types@1.2.1
|
|
13
|
+
- @backstage/plugin-app-node@0.1.31-next.2
|
|
14
|
+
- @backstage/plugin-auth-node@0.6.1-next.1
|
|
15
|
+
|
|
16
|
+
## 0.5.0-next.1
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 32be48c: **BREAKING**: Removed support for the old backend system.
|
|
21
|
+
|
|
22
|
+
As part of this change the plugin export from `/alpha` as been removed. If you are currently importing `@backstage/plugin-app-backend/alpha`, please update your import to `@backstage/plugin-app-backend`.
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- Updated dependencies
|
|
27
|
+
- @backstage/plugin-auth-node@0.6.1-next.1
|
|
28
|
+
- @backstage/backend-plugin-api@1.2.1-next.1
|
|
29
|
+
- @backstage/config@1.3.2
|
|
30
|
+
- @backstage/config-loader@1.9.6
|
|
31
|
+
- @backstage/errors@1.2.7
|
|
32
|
+
- @backstage/types@1.2.1
|
|
33
|
+
- @backstage/plugin-app-node@0.1.31-next.1
|
|
34
|
+
|
|
3
35
|
## 0.4.6-next.0
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
|
-
import { RootConfigService, LoggerService, AuthService, HttpAuthService, DatabaseService } from '@backstage/backend-plugin-api';
|
|
3
|
-
import express from 'express';
|
|
4
|
-
import { ConfigSchema } from '@backstage/config-loader';
|
|
5
2
|
|
|
6
3
|
/**
|
|
7
4
|
* The App plugin is responsible for serving the frontend app bundle and static assets.
|
|
@@ -9,62 +6,4 @@ import { ConfigSchema } from '@backstage/config-loader';
|
|
|
9
6
|
*/
|
|
10
7
|
declare const appPlugin: _backstage_backend_plugin_api.BackendFeature;
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
* @public
|
|
14
|
-
* @deprecated Please migrate to the new backend system as this will be removed in the future.
|
|
15
|
-
*/
|
|
16
|
-
interface RouterOptions {
|
|
17
|
-
config: RootConfigService;
|
|
18
|
-
logger: LoggerService;
|
|
19
|
-
auth?: AuthService;
|
|
20
|
-
httpAuth?: HttpAuthService;
|
|
21
|
-
/**
|
|
22
|
-
* If a database is provided it will be used to cache previously deployed static assets.
|
|
23
|
-
*
|
|
24
|
-
* This is a built-in alternative to using a `staticFallbackHandler`.
|
|
25
|
-
*/
|
|
26
|
-
database?: DatabaseService;
|
|
27
|
-
/**
|
|
28
|
-
* The name of the app package that content should be served from. The same app package should be
|
|
29
|
-
* added as a dependency to the backend package in order for it to be accessible at runtime.
|
|
30
|
-
*
|
|
31
|
-
* In a typical setup with a single app package this would be set to 'app'.
|
|
32
|
-
*/
|
|
33
|
-
appPackageName: string;
|
|
34
|
-
/**
|
|
35
|
-
* A request handler to handle requests for static content that are not present in the app bundle.
|
|
36
|
-
*
|
|
37
|
-
* This can be used to avoid issues with clients on older deployment versions trying to access lazy
|
|
38
|
-
* loaded content that is no longer present. Typically the requests would fall back to a long-term
|
|
39
|
-
* object store where all recently deployed versions of the app are present.
|
|
40
|
-
*
|
|
41
|
-
* Another option is to provide a `database` that will take care of storing the static assets instead.
|
|
42
|
-
*
|
|
43
|
-
* If both `database` and `staticFallbackHandler` are provided, the `database` will attempt to serve
|
|
44
|
-
* static assets first, and if they are not found, the `staticFallbackHandler` will be called.
|
|
45
|
-
*/
|
|
46
|
-
staticFallbackHandler?: express.Handler;
|
|
47
|
-
/**
|
|
48
|
-
* Disables the configuration injection. This can be useful if you're running in an environment
|
|
49
|
-
* with a read-only filesystem, or for some other reason don't want configuration to be injected.
|
|
50
|
-
*
|
|
51
|
-
* Note that this will cause the configuration used when building the app bundle to be used, unless
|
|
52
|
-
* a separate configuration loading strategy is set up.
|
|
53
|
-
*
|
|
54
|
-
* This also disables configuration injection though `APP_CONFIG_` environment variables.
|
|
55
|
-
*/
|
|
56
|
-
disableConfigInjection?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
* Provides a ConfigSchema.
|
|
60
|
-
*
|
|
61
|
-
*/
|
|
62
|
-
schema?: ConfigSchema;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* @public
|
|
66
|
-
* @deprecated Please migrate to the new backend system as this will be removed in the future.
|
|
67
|
-
*/
|
|
68
|
-
declare function createRouter(options: RouterOptions): Promise<express.Router>;
|
|
69
|
-
|
|
70
|
-
export { type RouterOptions, createRouter, appPlugin as default };
|
|
9
|
+
export { appPlugin as default };
|
|
@@ -31,7 +31,9 @@ async function createRouter(options) {
|
|
|
31
31
|
httpAuth,
|
|
32
32
|
schema
|
|
33
33
|
} = options;
|
|
34
|
-
const disableConfigInjection =
|
|
34
|
+
const disableConfigInjection = config.getOptionalBoolean(
|
|
35
|
+
"app.disableConfigInjection"
|
|
36
|
+
);
|
|
35
37
|
const disableStaticFallbackCache = config.getOptionalBoolean(
|
|
36
38
|
"app.disableStaticFallbackCache"
|
|
37
39
|
);
|
|
@@ -52,15 +54,15 @@ async function createRouter(options) {
|
|
|
52
54
|
env: process.env,
|
|
53
55
|
schema
|
|
54
56
|
});
|
|
55
|
-
const assetStore =
|
|
57
|
+
const assetStore = !disableStaticFallbackCache ? await StaticAssetsStore.StaticAssetsStore.create({
|
|
56
58
|
logger,
|
|
57
59
|
database: options.database
|
|
58
60
|
}) : void 0;
|
|
59
61
|
const router = Router__default.default();
|
|
60
62
|
router.use(helmet__default.default.frameguard({ action: "deny" }));
|
|
61
63
|
const publicDistDir = path.resolve(appDistDir, "public");
|
|
62
|
-
const enablePublicEntryPoint = await fs__default.default.pathExists(publicDistDir)
|
|
63
|
-
if (enablePublicEntryPoint
|
|
64
|
+
const enablePublicEntryPoint = await fs__default.default.pathExists(publicDistDir);
|
|
65
|
+
if (enablePublicEntryPoint) {
|
|
64
66
|
logger.info(
|
|
65
67
|
`App is running in protected mode, serving public content from ${publicDistDir}`
|
|
66
68
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DatabaseService,\n resolvePackagePath,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport { AppConfig } from '@backstage/config';\nimport helmet from 'helmet';\nimport express, { Request, Response } from 'express';\nimport Router from 'express-promise-router';\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport {\n createStaticAssetMiddleware,\n findStaticAssets,\n StaticAssetsStore,\n} from '../lib/assets';\nimport {\n CACHE_CONTROL_MAX_CACHE,\n CACHE_CONTROL_NO_CACHE,\n CACHE_CONTROL_REVALIDATE_CACHE,\n} from '../lib/headers';\nimport { ConfigSchema } from '@backstage/config-loader';\nimport {\n AuthService,\n HttpAuthService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport { injectConfig, readFrontendConfig } from '../lib/config';\n\n// express uses mime v1 while we only have types for mime v2\ntype Mime = { lookup(arg0: string): string };\n\n/**\n * @public\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n */\nexport interface RouterOptions {\n config: RootConfigService;\n logger: LoggerService;\n auth?: AuthService;\n httpAuth?: HttpAuthService;\n\n /**\n * If a database is provided it will be used to cache previously deployed static assets.\n *\n * This is a built-in alternative to using a `staticFallbackHandler`.\n */\n database?: DatabaseService;\n\n /**\n * The name of the app package that content should be served from. The same app package should be\n * added as a dependency to the backend package in order for it to be accessible at runtime.\n *\n * In a typical setup with a single app package this would be set to 'app'.\n */\n appPackageName: string;\n\n /**\n * A request handler to handle requests for static content that are not present in the app bundle.\n *\n * This can be used to avoid issues with clients on older deployment versions trying to access lazy\n * loaded content that is no longer present. Typically the requests would fall back to a long-term\n * object store where all recently deployed versions of the app are present.\n *\n * Another option is to provide a `database` that will take care of storing the static assets instead.\n *\n * If both `database` and `staticFallbackHandler` are provided, the `database` will attempt to serve\n * static assets first, and if they are not found, the `staticFallbackHandler` will be called.\n */\n staticFallbackHandler?: express.Handler;\n\n /**\n * Disables the configuration injection. This can be useful if you're running in an environment\n * with a read-only filesystem, or for some other reason don't want configuration to be injected.\n *\n * Note that this will cause the configuration used when building the app bundle to be used, unless\n * a separate configuration loading strategy is set up.\n *\n * This also disables configuration injection though `APP_CONFIG_` environment variables.\n */\n disableConfigInjection?: boolean;\n\n /**\n *\n * Provides a ConfigSchema.\n *\n */\n schema?: ConfigSchema;\n}\n\n/**\n * @public\n * @deprecated Please migrate to the new backend system as this will be removed in the future.\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n appPackageName,\n staticFallbackHandler,\n auth,\n httpAuth,\n schema,\n } = options;\n\n const disableConfigInjection =\n options.disableConfigInjection ??\n config.getOptionalBoolean('app.disableConfigInjection');\n const disableStaticFallbackCache = config.getOptionalBoolean(\n 'app.disableStaticFallbackCache',\n );\n\n const appDistDir = resolvePackagePath(appPackageName, 'dist');\n const staticDir = resolvePath(appDistDir, 'static');\n\n if (!(await fs.pathExists(staticDir))) {\n if (process.env.NODE_ENV === 'production') {\n logger.error(\n `Can't serve static app content from ${staticDir}, directory doesn't exist`,\n );\n }\n\n return Router();\n }\n\n logger.info(`Serving static app content from ${appDistDir}`);\n\n const appConfigs = disableConfigInjection\n ? undefined\n : await readFrontendConfig({\n config,\n appDistDir,\n env: process.env,\n schema,\n });\n\n const assetStore =\n options.database && !disableStaticFallbackCache\n ? await StaticAssetsStore.create({\n logger,\n database: options.database,\n })\n : undefined;\n\n const router = Router();\n\n router.use(helmet.frameguard({ action: 'deny' }));\n\n const publicDistDir = resolvePath(appDistDir, 'public');\n\n const enablePublicEntryPoint =\n (await fs.pathExists(publicDistDir)) && auth && httpAuth;\n\n if (enablePublicEntryPoint && auth && httpAuth) {\n logger.info(\n `App is running in protected mode, serving public content from ${publicDistDir}`,\n );\n\n const publicRouter = Router();\n\n publicRouter.use(async (req, res, next) => {\n try {\n const credentials = await httpAuth.credentials(req, {\n allow: ['user', 'service', 'none'],\n allowLimitedAccess: true,\n });\n\n if (credentials.principal.type === 'none') {\n next();\n } else {\n next('router');\n }\n } catch {\n // If we fail to authenticate, make sure the session cookie is cleared\n // and continue as unauthenticated. If the user is logged in they will\n // immediately be redirected back to the protected app via the POST.\n await httpAuth.issueUserCookie(res, {\n credentials: await auth.getNoneCredentials(),\n });\n next();\n }\n });\n\n publicRouter.post(\n '*',\n express.urlencoded({ extended: true }),\n async (req, res, next) => {\n if (req.body.type === 'sign-in') {\n const credentials = await auth.authenticate(req.body.token);\n\n if (!auth.isPrincipal(credentials, 'user')) {\n throw new AuthenticationError('Invalid token, not a user');\n }\n\n await httpAuth.issueUserCookie(res, {\n credentials,\n });\n\n // Resume as if it was a GET request towards the outer protected router, serving index.html\n req.method = 'GET';\n next('router');\n } else {\n throw new InputError(\n 'Invalid POST request to app-backend wildcard endpoint',\n );\n }\n },\n );\n\n publicRouter.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'public' }),\n rootDir: publicDistDir,\n assetStore: assetStore?.withNamespace('public'),\n appConfigs, // TODO(Rugvip): We should not be including the full config here\n }),\n );\n\n router.use(publicRouter);\n }\n\n router.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'main' }),\n rootDir: appDistDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n }),\n );\n\n return router;\n}\n\nasync function createEntryPointRouter({\n logger,\n rootDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n}: {\n logger: LoggerService;\n rootDir: string;\n assetStore?: StaticAssetsStore;\n staticFallbackHandler?: express.Handler;\n appConfigs?: AppConfig[];\n}) {\n const staticDir = resolvePath(rootDir, 'static');\n\n const injectResult =\n appConfigs &&\n (await injectConfig({ appConfigs, logger, rootDir, staticDir }));\n\n const router = Router();\n\n // Use a separate router for static content so that a fallback can be provided by backend\n const staticRouter = Router();\n staticRouter.use(\n express.static(staticDir, {\n setHeaders: (res, path) => {\n if (injectResult?.injectedPath === path) {\n res.setHeader('Cache-Control', CACHE_CONTROL_REVALIDATE_CACHE);\n } else {\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n }\n },\n }),\n );\n\n if (assetStore) {\n const assets = await findStaticAssets(staticDir);\n await assetStore.storeAssets(assets);\n // Remove any assets that are older than 7 days\n await assetStore.trimAssets({ maxAgeSeconds: 60 * 60 * 24 * 7 });\n\n staticRouter.use(createStaticAssetMiddleware(assetStore));\n }\n\n if (staticFallbackHandler) {\n staticRouter.use(staticFallbackHandler);\n }\n staticRouter.use((_req: Request, res: Response) => {\n res.status(404).end();\n });\n\n router.use('/static', staticRouter);\n\n const rootRouter = Router();\n rootRouter.use((req, _res, next) => {\n // Make sure / and /index.html are handled by the HTML5 route below\n if (req.path === '/' || req.path === '/index.html') {\n next('router');\n } else {\n next();\n }\n });\n rootRouter.use(\n express.static(rootDir, {\n setHeaders: (res, path) => {\n // The Cache-Control header instructs the browser to not cache html files since it might\n // link to static assets from recently deployed versions.\n if (\n (express.static.mime as unknown as Mime).lookup(path) === 'text/html'\n ) {\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n }\n },\n }),\n );\n router.use(rootRouter);\n\n // HTML5 routing\n router.get('/*', (_req, res) => {\n if (injectResult?.indexHtmlContent) {\n res.setHeader('Content-Type', 'text/html; charset=utf-8');\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n res.send(injectResult.indexHtmlContent);\n } else {\n res.sendFile(resolvePath(rootDir, 'index.html'), {\n headers: {\n // The Cache-Control header instructs the browser to not cache the index.html since it might\n // link to static assets from recently deployed versions.\n 'cache-control': CACHE_CONTROL_NO_CACHE,\n },\n });\n }\n });\n\n return router;\n}\n"],"names":["resolvePackagePath","resolvePath","fs","Router","readFrontendConfig","StaticAssetsStore","helmet","express","AuthenticationError","InputError","injectConfig","CACHE_CONTROL_REVALIDATE_CACHE","CACHE_CONTROL_MAX_CACHE","findStaticAssets","createStaticAssetMiddleware","CACHE_CONTROL_NO_CACHE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA+GA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA;AAAA,IACJ,MAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA,qBAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACE,GAAA,OAAA;AAEJ,EAAA,MAAM,sBACJ,GAAA,OAAA,CAAQ,sBACR,IAAA,MAAA,CAAO,mBAAmB,4BAA4B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CAAA;AACD,EAAW,UAAA,CAAA,GAAA;AAAA,IACTI,wBAAA,CAAQ,OAAO,OAAS,EAAA;AAAA,MACtB,UAAA,EAAY,CAAC,GAAA,EAAK,IAAS,KAAA;AAGzB,QAAA,IACGA,yBAAQ,MAAO,CAAA,IAAA,CAAyB,MAAO,CAAA,IAAI,MAAM,WAC1D,EAAA;AACA,UAAI,GAAA,CAAA,SAAA,CAAU,iBAAiBQ,8BAAsB,CAAA;AAAA;AACvD;AACF,KACD;AAAA,GACH;AACA,EAAA,MAAA,CAAO,IAAI,UAAU,CAAA;AAGrB,EAAA,MAAA,CAAO,GAAI,CAAA,IAAA,EAAM,CAAC,IAAA,EAAM,GAAQ,KAAA;AAC9B,IAAA,IAAI,cAAc,gBAAkB,EAAA;AAClC,MAAI,GAAA,CAAA,SAAA,CAAU,gBAAgB,0BAA0B,CAAA;AACxD,MAAI,GAAA,CAAA,SAAA,CAAU,iBAAiBA,8BAAsB,CAAA;AACrD,MAAI,GAAA,CAAA,IAAA,CAAK,aAAa,gBAAgB,CAAA;AAAA,KACjC,MAAA;AACL,MAAA,GAAA,CAAI,QAAS,CAAAd,YAAA,CAAY,OAAS,EAAA,YAAY,CAAG,EAAA;AAAA,QAC/C,OAAS,EAAA;AAAA;AAAA;AAAA,UAGP,eAAiB,EAAAc;AAAA;AACnB,OACD,CAAA;AAAA;AACH,GACD,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"router.cjs.js","sources":["../../src/service/router.ts"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n DatabaseService,\n resolvePackagePath,\n RootConfigService,\n} from '@backstage/backend-plugin-api';\nimport type { AppConfig } from '@backstage/config';\nimport helmet from 'helmet';\nimport express, { Request, Response } from 'express';\nimport Router from 'express-promise-router';\nimport fs from 'fs-extra';\nimport { resolve as resolvePath } from 'path';\nimport {\n createStaticAssetMiddleware,\n findStaticAssets,\n StaticAssetsStore,\n} from '../lib/assets';\nimport {\n CACHE_CONTROL_MAX_CACHE,\n CACHE_CONTROL_NO_CACHE,\n CACHE_CONTROL_REVALIDATE_CACHE,\n} from '../lib/headers';\nimport type { ConfigSchema } from '@backstage/config-loader';\nimport {\n AuthService,\n HttpAuthService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport { AuthenticationError, InputError } from '@backstage/errors';\nimport { injectConfig, readFrontendConfig } from '../lib/config';\n\n// express uses mime v1 while we only have types for mime v2\ntype Mime = { lookup(arg0: string): string };\n\n/**\n * @internal\n */\nexport interface RouterOptions {\n config: RootConfigService;\n logger: LoggerService;\n auth: AuthService;\n httpAuth: HttpAuthService;\n\n /**\n * If a database is provided it will be used to cache previously deployed static assets.\n *\n * This is a built-in alternative to using a `staticFallbackHandler`.\n */\n database: DatabaseService;\n\n /**\n * The name of the app package that content should be served from. The same app package should be\n * added as a dependency to the backend package in order for it to be accessible at runtime.\n *\n * In a typical setup with a single app package this would be set to 'app'.\n */\n appPackageName: string;\n\n /**\n * A request handler to handle requests for static content that are not present in the app bundle.\n *\n * This can be used to avoid issues with clients on older deployment versions trying to access lazy\n * loaded content that is no longer present. Typically the requests would fall back to a long-term\n * object store where all recently deployed versions of the app are present.\n *\n * Another option is to provide a `database` that will take care of storing the static assets instead.\n *\n * If both `database` and `staticFallbackHandler` are provided, the `database` will attempt to serve\n * static assets first, and if they are not found, the `staticFallbackHandler` will be called.\n */\n staticFallbackHandler?: express.Handler;\n\n /**\n *\n * Provides a ConfigSchema.\n *\n */\n schema?: ConfigSchema;\n}\n\n/**\n * @internal\n */\nexport async function createRouter(\n options: RouterOptions,\n): Promise<express.Router> {\n const {\n config,\n logger,\n appPackageName,\n staticFallbackHandler,\n auth,\n httpAuth,\n schema,\n } = options;\n\n const disableConfigInjection = config.getOptionalBoolean(\n 'app.disableConfigInjection',\n );\n const disableStaticFallbackCache = config.getOptionalBoolean(\n 'app.disableStaticFallbackCache',\n );\n\n const appDistDir = resolvePackagePath(appPackageName, 'dist');\n const staticDir = resolvePath(appDistDir, 'static');\n\n if (!(await fs.pathExists(staticDir))) {\n if (process.env.NODE_ENV === 'production') {\n logger.error(\n `Can't serve static app content from ${staticDir}, directory doesn't exist`,\n );\n }\n\n return Router();\n }\n\n logger.info(`Serving static app content from ${appDistDir}`);\n\n const appConfigs = disableConfigInjection\n ? undefined\n : await readFrontendConfig({\n config,\n appDistDir,\n env: process.env,\n schema,\n });\n\n const assetStore = !disableStaticFallbackCache\n ? await StaticAssetsStore.create({\n logger,\n database: options.database,\n })\n : undefined;\n\n const router = Router();\n\n router.use(helmet.frameguard({ action: 'deny' }));\n\n const publicDistDir = resolvePath(appDistDir, 'public');\n\n const enablePublicEntryPoint = await fs.pathExists(publicDistDir);\n\n if (enablePublicEntryPoint) {\n logger.info(\n `App is running in protected mode, serving public content from ${publicDistDir}`,\n );\n\n const publicRouter = Router();\n\n publicRouter.use(async (req, res, next) => {\n try {\n const credentials = await httpAuth.credentials(req, {\n allow: ['user', 'service', 'none'],\n allowLimitedAccess: true,\n });\n\n if (credentials.principal.type === 'none') {\n next();\n } else {\n next('router');\n }\n } catch {\n // If we fail to authenticate, make sure the session cookie is cleared\n // and continue as unauthenticated. If the user is logged in they will\n // immediately be redirected back to the protected app via the POST.\n await httpAuth.issueUserCookie(res, {\n credentials: await auth.getNoneCredentials(),\n });\n next();\n }\n });\n\n publicRouter.post(\n '*',\n express.urlencoded({ extended: true }),\n async (req, res, next) => {\n if (req.body.type === 'sign-in') {\n const credentials = await auth.authenticate(req.body.token);\n\n if (!auth.isPrincipal(credentials, 'user')) {\n throw new AuthenticationError('Invalid token, not a user');\n }\n\n await httpAuth.issueUserCookie(res, {\n credentials,\n });\n\n // Resume as if it was a GET request towards the outer protected router, serving index.html\n req.method = 'GET';\n next('router');\n } else {\n throw new InputError(\n 'Invalid POST request to app-backend wildcard endpoint',\n );\n }\n },\n );\n\n publicRouter.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'public' }),\n rootDir: publicDistDir,\n assetStore: assetStore?.withNamespace('public'),\n appConfigs, // TODO(Rugvip): We should not be including the full config here\n }),\n );\n\n router.use(publicRouter);\n }\n\n router.use(\n await createEntryPointRouter({\n logger: logger.child({ entry: 'main' }),\n rootDir: appDistDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n }),\n );\n\n return router;\n}\n\nasync function createEntryPointRouter({\n logger,\n rootDir,\n assetStore,\n staticFallbackHandler,\n appConfigs,\n}: {\n logger: LoggerService;\n rootDir: string;\n assetStore?: StaticAssetsStore;\n staticFallbackHandler?: express.Handler;\n appConfigs?: AppConfig[];\n}) {\n const staticDir = resolvePath(rootDir, 'static');\n\n const injectResult =\n appConfigs &&\n (await injectConfig({ appConfigs, logger, rootDir, staticDir }));\n\n const router = Router();\n\n // Use a separate router for static content so that a fallback can be provided by backend\n const staticRouter = Router();\n staticRouter.use(\n express.static(staticDir, {\n setHeaders: (res, path) => {\n if (injectResult?.injectedPath === path) {\n res.setHeader('Cache-Control', CACHE_CONTROL_REVALIDATE_CACHE);\n } else {\n res.setHeader('Cache-Control', CACHE_CONTROL_MAX_CACHE);\n }\n },\n }),\n );\n\n if (assetStore) {\n const assets = await findStaticAssets(staticDir);\n await assetStore.storeAssets(assets);\n // Remove any assets that are older than 7 days\n await assetStore.trimAssets({ maxAgeSeconds: 60 * 60 * 24 * 7 });\n\n staticRouter.use(createStaticAssetMiddleware(assetStore));\n }\n\n if (staticFallbackHandler) {\n staticRouter.use(staticFallbackHandler);\n }\n staticRouter.use((_req: Request, res: Response) => {\n res.status(404).end();\n });\n\n router.use('/static', staticRouter);\n\n const rootRouter = Router();\n rootRouter.use((req, _res, next) => {\n // Make sure / and /index.html are handled by the HTML5 route below\n if (req.path === '/' || req.path === '/index.html') {\n next('router');\n } else {\n next();\n }\n });\n rootRouter.use(\n express.static(rootDir, {\n setHeaders: (res, path) => {\n // The Cache-Control header instructs the browser to not cache html files since it might\n // link to static assets from recently deployed versions.\n if (\n (express.static.mime as unknown as Mime).lookup(path) === 'text/html'\n ) {\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n }\n },\n }),\n );\n router.use(rootRouter);\n\n // HTML5 routing\n router.get('/*', (_req, res) => {\n if (injectResult?.indexHtmlContent) {\n res.setHeader('Content-Type', 'text/html; charset=utf-8');\n res.setHeader('Cache-Control', CACHE_CONTROL_NO_CACHE);\n res.send(injectResult.indexHtmlContent);\n } else {\n res.sendFile(resolvePath(rootDir, 'index.html'), {\n headers: {\n // The Cache-Control header instructs the browser to not cache the index.html since it might\n // link to static assets from recently deployed versions.\n 'cache-control': CACHE_CONTROL_NO_CACHE,\n },\n });\n }\n });\n\n return router;\n}\n"],"names":["resolvePackagePath","resolvePath","fs","Router","readFrontendConfig","StaticAssetsStore","helmet","express","AuthenticationError","InputError","injectConfig","CACHE_CONTROL_REVALIDATE_CACHE","CACHE_CONTROL_MAX_CACHE","findStaticAssets","createStaticAssetMiddleware","CACHE_CONTROL_NO_CACHE"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkGA,eAAsB,aACpB,OACyB,EAAA;AACzB,EAAM,MAAA;AAAA,IACJ,MAAA;AAAA,IACA,MAAA;AAAA,IACA,cAAA;AAAA,IACA,qBAAA;AAAA,IACA,IAAA;AAAA,IACA,QAAA;AAAA,IACA;AAAA,GACE,GAAA,OAAA;AAEJ,EAAA,MAAM,yBAAyB,MAAO,CAAA,kBAAA;AAAA,IACpC;AAAA,GACF;AACA,EAAA,MAAM,6BAA6B,MAAO,CAAA,kBAAA;AAAA,IACxC;AAAA,GACF;AAEA,EAAM,MAA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B,QAAA,IACGA,yBAAQ,MAAO,CAAA,IAAA,CAAyB,MAAO,CAAA,IAAI,MAAM,WAC1D,EAAA;AACA,UAAI,GAAA,CAAA,SAAA,CAAU,iBAAiBQ,8BAAsB,CAAA;AAAA;AACvD;AACF,KACD;AAAA,GACH;AACA,EAAA,MAAA,CAAO,IAAI,UAAU,CAAA;AAGrB,EAAA,MAAA,CAAO,GAAI,CAAA,IAAA,EAAM,CAAC,IAAA,EAAM,GAAQ,KAAA;AAC9B,IAAA,IAAI,cAAc,gBAAkB,EAAA;AAClC,MAAI,GAAA,CAAA,SAAA,CAAU,gBAAgB,0BAA0B,CAAA;AACxD,MAAI,GAAA,CAAA,SAAA,CAAU,iBAAiBA,8BAAsB,CAAA;AACrD,MAAI,GAAA,CAAA,IAAA,CAAK,aAAa,gBAAgB,CAAA;AAAA,KACjC,MAAA;AACL,MAAA,GAAA,CAAI,QAAS,CAAAd,YAAA,CAAY,OAAS,EAAA,YAAY,CAAG,EAAA;AAAA,QAC/C,OAAS,EAAA;AAAA;AAAA;AAAA,UAGP,eAAiB,EAAAc;AAAA;AACnB,OACD,CAAA;AAAA;AACH,GACD,CAAA;AAED,EAAO,OAAA,MAAA;AACT;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-app-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0-next.2",
|
|
4
4
|
"description": "A Backstage backend plugin that serves the Backstage frontend app",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "backend-plugin",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"@backstage/plugin-app-node"
|
|
12
12
|
],
|
|
13
13
|
"features": {
|
|
14
|
-
".": "@backstage/BackendFeature"
|
|
15
|
-
"./alpha": "@backstage/BackendFeature"
|
|
14
|
+
".": "@backstage/BackendFeature"
|
|
16
15
|
}
|
|
17
16
|
},
|
|
18
17
|
"publishConfig": {
|
|
@@ -35,26 +34,10 @@
|
|
|
35
34
|
"types": "./dist/index.d.ts",
|
|
36
35
|
"default": "./dist/index.cjs.js"
|
|
37
36
|
},
|
|
38
|
-
"./alpha": {
|
|
39
|
-
"backstage": "@backstage/BackendFeature",
|
|
40
|
-
"require": "./dist/alpha.cjs.js",
|
|
41
|
-
"types": "./dist/alpha.d.ts",
|
|
42
|
-
"default": "./dist/alpha.cjs.js"
|
|
43
|
-
},
|
|
44
37
|
"./package.json": "./package.json"
|
|
45
38
|
},
|
|
46
39
|
"main": "./dist/index.cjs.js",
|
|
47
40
|
"types": "./dist/index.d.ts",
|
|
48
|
-
"typesVersions": {
|
|
49
|
-
"*": {
|
|
50
|
-
"index": [
|
|
51
|
-
"dist/index.d.ts"
|
|
52
|
-
],
|
|
53
|
-
"alpha": [
|
|
54
|
-
"dist/alpha.d.ts"
|
|
55
|
-
]
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
41
|
"files": [
|
|
59
42
|
"dist",
|
|
60
43
|
"config.d.ts",
|
|
@@ -71,14 +54,13 @@
|
|
|
71
54
|
"test": "backstage-cli package test"
|
|
72
55
|
},
|
|
73
56
|
"dependencies": {
|
|
74
|
-
"@backstage/backend-plugin-api": "1.2.1-next.
|
|
57
|
+
"@backstage/backend-plugin-api": "1.2.1-next.1",
|
|
75
58
|
"@backstage/config": "1.3.2",
|
|
76
|
-
"@backstage/config-loader": "1.
|
|
59
|
+
"@backstage/config-loader": "1.10.0-next.0",
|
|
77
60
|
"@backstage/errors": "1.2.7",
|
|
78
|
-
"@backstage/plugin-app-node": "0.1.31-next.
|
|
79
|
-
"@backstage/plugin-auth-node": "0.6.1-next.
|
|
61
|
+
"@backstage/plugin-app-node": "0.1.31-next.2",
|
|
62
|
+
"@backstage/plugin-auth-node": "0.6.1-next.1",
|
|
80
63
|
"@backstage/types": "1.2.1",
|
|
81
|
-
"@types/express": "^4.17.6",
|
|
82
64
|
"express": "^4.17.1",
|
|
83
65
|
"express-promise-router": "^4.1.0",
|
|
84
66
|
"fs-extra": "^11.2.0",
|
|
@@ -90,11 +72,12 @@
|
|
|
90
72
|
"yn": "^4.0.0"
|
|
91
73
|
},
|
|
92
74
|
"devDependencies": {
|
|
93
|
-
"@backstage/backend-app-api": "1.2.1-next.
|
|
94
|
-
"@backstage/backend-defaults": "0.8.2-next.
|
|
95
|
-
"@backstage/backend-test-utils": "1.3.1-next.
|
|
96
|
-
"@backstage/cli": "0.
|
|
75
|
+
"@backstage/backend-app-api": "1.2.1-next.2",
|
|
76
|
+
"@backstage/backend-defaults": "0.8.2-next.2",
|
|
77
|
+
"@backstage/backend-test-utils": "1.3.1-next.2",
|
|
78
|
+
"@backstage/cli": "0.31.0-next.1",
|
|
97
79
|
"@backstage/types": "1.2.1",
|
|
80
|
+
"@types/express": "^4.17.6",
|
|
98
81
|
"@types/supertest": "^2.0.8",
|
|
99
82
|
"supertest": "^7.0.0"
|
|
100
83
|
},
|
package/dist/alpha.cjs.js
DELETED
package/dist/alpha.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.cjs.js","sources":["../src/alpha.ts"],"sourcesContent":["/*\n * Copyright 2023 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { appPlugin } from './service/appPlugin';\n\n/** @alpha */\nconst _appPlugin = appPlugin;\nexport default _appPlugin;\n"],"names":["appPlugin"],"mappings":";;;;;;AAmBA,MAAM,UAAa,GAAAA;;;;"}
|