@backstage/backend-app-api 0.2.4 → 0.3.0-next.1
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.
Potentially problematic release.
This version of @backstage/backend-app-api might be problematic. Click here for more details.
- package/CHANGELOG.md +36 -0
- package/alpha/package.json +1 -1
- package/dist/index.alpha.d.ts +270 -9
- package/dist/index.beta.d.ts +270 -9
- package/dist/index.cjs.js +844 -156
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +270 -9
- package/package.json +26 -6
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/services/implementations/lifecycleService.ts","../src/wiring/BackendInitializer.ts","../src/wiring/ServiceRegistry.ts","../src/wiring/BackstageBackend.ts","../src/wiring/types.ts","../src/services/implementations/cacheService.ts","../src/services/implementations/configService.ts","../src/services/implementations/databaseService.ts","../src/services/implementations/discoveryService.ts","../src/services/implementations/loggerService.ts","../src/services/implementations/rootLoggerService.ts","../src/services/implementations/permissionsService.ts","../src/services/implementations/schedulerService.ts","../src/services/implementations/tokenManagerService.ts","../src/services/implementations/urlReaderService.ts","../src/services/implementations/httpRouterService.ts"],"sourcesContent":["/*\n * Copyright 2022 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 */\nimport {\n LifecycleService,\n createServiceFactory,\n coreServices,\n loggerToWinstonLogger,\n LifecycleServiceShutdownHook,\n} from '@backstage/backend-plugin-api';\nimport { Logger } from 'winston';\n\nconst CALLBACKS = ['SIGTERM', 'SIGINT', 'beforeExit'];\nexport class BackendLifecycleImpl {\n constructor(private readonly logger: Logger) {\n CALLBACKS.map(signal => process.on(signal, () => this.shutdown()));\n }\n\n #isCalled = false;\n #shutdownTasks: Array<LifecycleServiceShutdownHook & { pluginId: string }> =\n [];\n\n addShutdownHook(\n options: LifecycleServiceShutdownHook & { pluginId: string },\n ): void {\n this.#shutdownTasks.push(options);\n }\n\n async shutdown(): Promise<void> {\n if (this.#isCalled) {\n return;\n }\n this.#isCalled = true;\n\n this.logger.info(`Running ${this.#shutdownTasks.length} shutdown tasks...`);\n await Promise.all(\n this.#shutdownTasks.map(hook =>\n Promise.resolve()\n .then(() => hook.fn())\n .catch(e => {\n this.logger.error(\n `Shutdown hook registered by plugin '${hook.pluginId}' failed with: ${e}`,\n );\n })\n .then(() =>\n this.logger.info(\n `Successfully ran shutdown hook registered by plugin ${hook.pluginId}`,\n ),\n ),\n ),\n );\n }\n}\n\nclass PluginScopedLifecycleImpl implements LifecycleService {\n constructor(\n private readonly lifecycle: BackendLifecycleImpl,\n private readonly pluginId: string,\n ) {}\n addShutdownHook(options: LifecycleServiceShutdownHook): void {\n this.lifecycle.addShutdownHook({ ...options, pluginId: this.pluginId });\n }\n}\n\n/**\n * Allows plugins to register shutdown hooks that are run when the process is about to exit.\n * @public */\nexport const lifecycleFactory = createServiceFactory({\n service: coreServices.lifecycle,\n deps: {\n logger: coreServices.rootLogger,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ logger }) {\n const rootLifecycle = new BackendLifecycleImpl(\n loggerToWinstonLogger(logger),\n );\n return async ({ plugin }) => {\n return new PluginScopedLifecycleImpl(rootLifecycle, plugin.getId());\n };\n },\n});\n","/*\n * Copyright 2022 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 BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackendLifecycleImpl } from '../services/implementations/lifecycleService';\nimport {\n BackendRegisterInit,\n EnumerableServiceHolder,\n ServiceOrExtensionPoint,\n} from './types';\n\nexport class BackendInitializer {\n #started = false;\n #features = new Map<BackendFeature, unknown>();\n #registerInits = new Array<BackendRegisterInit>();\n #extensionPoints = new Map<ExtensionPoint<unknown>, unknown>();\n #serviceHolder: EnumerableServiceHolder;\n\n constructor(serviceHolder: EnumerableServiceHolder) {\n this.#serviceHolder = serviceHolder;\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n pluginId: string,\n ) {\n const result = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(deps)) {\n const extensionPoint = this.#extensionPoints.get(\n ref as ExtensionPoint<unknown>,\n );\n if (extensionPoint) {\n result.set(name, extensionPoint);\n } else {\n const impl = await this.#serviceHolder.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n result.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No extension point or service available for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add<TOptions>(feature: BackendFeature, options?: TOptions) {\n if (this.#started) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#features.set(feature, options);\n }\n\n async start(): Promise<void> {\n if (this.#started) {\n throw new Error('Backend has already started');\n }\n this.#started = true;\n\n // Initialize all root scoped services\n for (const ref of this.#serviceHolder.getServiceRefs()) {\n if (ref.scope === 'root') {\n await this.#serviceHolder.get(ref, 'root');\n }\n }\n\n // Initialize all features\n for (const [feature] of this.#features) {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n let registerInit: BackendRegisterInit | undefined = undefined;\n\n feature.register({\n registerExtensionPoint: (extensionPointRef, impl) => {\n if (registerInit) {\n throw new Error('registerExtensionPoint called after registerInit');\n }\n if (this.#extensionPoints.has(extensionPointRef)) {\n throw new Error(`API ${extensionPointRef.id} already registered`);\n }\n this.#extensionPoints.set(extensionPointRef, impl);\n provides.add(extensionPointRef);\n },\n registerInit: registerOptions => {\n if (registerInit) {\n throw new Error('registerInit must only be called once');\n }\n registerInit = {\n id: feature.id,\n provides,\n consumes: new Set(Object.values(registerOptions.deps)),\n deps: registerOptions.deps,\n init: registerOptions.init as BackendRegisterInit['init'],\n };\n },\n });\n\n if (!registerInit) {\n throw new Error(\n `registerInit was not called by register in ${feature.id}`,\n );\n }\n\n this.#registerInits.push(registerInit);\n }\n\n const orderedRegisterResults = this.#resolveInitOrder(this.#registerInits);\n\n for (const registerInit of orderedRegisterResults) {\n const deps = await this.#getInitDeps(registerInit.deps, registerInit.id);\n await registerInit.init(deps);\n }\n }\n\n #resolveInitOrder(registerInits: Array<BackendRegisterInit>) {\n let registerInitsToOrder = registerInits.slice();\n const orderedRegisterInits = new Array<BackendRegisterInit>();\n\n // TODO: Validate duplicates\n\n while (registerInitsToOrder.length > 0) {\n const toRemove = new Set<unknown>();\n\n for (const registerInit of registerInitsToOrder) {\n const unInitializedDependents = [];\n\n for (const provided of registerInit.provides) {\n if (\n registerInitsToOrder.some(\n init => init !== registerInit && init.consumes.has(provided),\n )\n ) {\n unInitializedDependents.push(provided);\n }\n }\n\n if (unInitializedDependents.length === 0) {\n orderedRegisterInits.push(registerInit);\n toRemove.add(registerInit);\n }\n }\n\n registerInitsToOrder = registerInitsToOrder.filter(r => !toRemove.has(r));\n }\n\n return orderedRegisterInits;\n }\n\n async stop(): Promise<void> {\n if (!this.#started) {\n return;\n }\n\n const lifecycleService = await this.#serviceHolder.get(\n coreServices.lifecycle,\n 'root',\n );\n\n // TODO(Rugvip): Find a better way to do this\n const lifecycle = (lifecycleService as any)?.lifecycle;\n if (lifecycle instanceof BackendLifecycleImpl) {\n await lifecycle.shutdown();\n } else {\n throw new Error('Unexpected lifecycle service implementation');\n }\n }\n}\n","/*\n * Copyright 2022 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 ServiceFactory,\n ServiceRef,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { stringifyError } from '@backstage/errors';\nimport { EnumerableServiceHolder } from './types';\n/**\n * Keep in sync with `@backstage/backend-plugin-api/src/services/system/types.ts`\n * @internal\n */\nexport type InternalServiceRef<T> = ServiceRef<T> & {\n __defaultFactory?: (\n service: ServiceRef<T>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;\n};\n\nexport class ServiceRegistry implements EnumerableServiceHolder {\n readonly #providedFactories: Map<string, ServiceFactory>;\n readonly #loadedDefaultFactories: Map<Function, Promise<ServiceFactory>>;\n readonly #implementations: Map<\n ServiceFactory,\n {\n factoryFunc: Promise<\n (deps: { [name in string]: unknown }) => Promise<unknown>\n >;\n byPlugin: Map<string, Promise<unknown>>;\n }\n >;\n\n constructor(\n factories: Array<ServiceFactory<unknown> | (() => ServiceFactory<unknown>)>,\n ) {\n this.#providedFactories = new Map(\n factories.map(f => {\n if (typeof f === 'function') {\n const cf = f();\n return [cf.service.id, cf];\n }\n return [f.service.id, f];\n }),\n );\n this.#loadedDefaultFactories = new Map();\n this.#implementations = new Map();\n }\n\n #resolveFactory(\n ref: ServiceRef<unknown>,\n pluginId: string,\n ): Promise<ServiceFactory> | undefined {\n // Special case handling of the plugin metadata service, generating a custom factory for it each time\n if (ref.id === coreServices.pluginMetadata.id) {\n return Promise.resolve({\n scope: 'plugin',\n service: coreServices.pluginMetadata,\n deps: {},\n factory: async () => async () => ({\n getId() {\n return pluginId;\n },\n }),\n });\n }\n\n let resolvedFactory: Promise<ServiceFactory> | ServiceFactory | undefined =\n this.#providedFactories.get(ref.id);\n const { __defaultFactory: defaultFactory } =\n ref as InternalServiceRef<unknown>;\n if (!resolvedFactory && !defaultFactory) {\n return undefined;\n }\n\n if (!resolvedFactory) {\n let loadedFactory = this.#loadedDefaultFactories.get(defaultFactory!);\n if (!loadedFactory) {\n loadedFactory = Promise.resolve()\n .then(() => defaultFactory!(ref))\n .then(f =>\n typeof f === 'function' ? f() : f,\n ) as Promise<ServiceFactory>;\n this.#loadedDefaultFactories.set(defaultFactory!, loadedFactory);\n }\n resolvedFactory = loadedFactory.catch(error => {\n throw new Error(\n `Failed to instantiate service '${\n ref.id\n }' because the default factory loader threw an error, ${stringifyError(\n error,\n )}`,\n );\n });\n }\n\n return Promise.resolve(resolvedFactory);\n }\n\n #separateMapForTheRootService = new Map<ServiceFactory, Promise<unknown>>();\n\n #checkForMissingDeps(factory: ServiceFactory, pluginId: string) {\n const missingDeps = Object.values(factory.deps).filter(ref => {\n if (ref.id === coreServices.pluginMetadata.id) {\n return false;\n }\n if (this.#providedFactories.get(ref.id)) {\n return false;\n }\n\n return !(ref as InternalServiceRef<unknown>).__defaultFactory;\n });\n\n if (missingDeps.length) {\n const missing = missingDeps.map(r => `'${r.id}'`).join(', ');\n throw new Error(\n `Failed to instantiate service '${factory.service.id}' for '${pluginId}' because the following dependent services are missing: ${missing}`,\n );\n }\n }\n\n getServiceRefs(): ServiceRef<unknown>[] {\n return Array.from(this.#providedFactories.values()).map(f => f.service);\n }\n\n get<T>(ref: ServiceRef<T>, pluginId: string): Promise<T> | undefined {\n return this.#resolveFactory(ref, pluginId)?.then(factory => {\n if (factory.scope === 'root') {\n let existing = this.#separateMapForTheRootService.get(factory);\n if (!existing) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope !== 'root') {\n throw new Error(\n `Failed to instantiate 'root' scoped service '${ref.id}' because it depends on '${serviceRef.scope}' scoped service '${serviceRef.id}'.`,\n );\n }\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n\n existing = Promise.all(rootDeps).then(entries =>\n factory.factory(Object.fromEntries(entries)),\n );\n this.#separateMapForTheRootService.set(factory, existing);\n }\n return existing as Promise<T>;\n }\n\n let implementation = this.#implementations.get(factory);\n if (!implementation) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope === 'root') {\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n }\n\n implementation = {\n factoryFunc: Promise.all(rootDeps)\n .then(entries => factory.factory(Object.fromEntries(entries)))\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' because the top-level factory function threw an error, ${cause}`,\n );\n }),\n byPlugin: new Map(),\n };\n\n this.#implementations.set(factory, implementation);\n }\n\n let result = implementation.byPlugin.get(pluginId) as Promise<any>;\n if (!result) {\n const allDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n const target = this.get(serviceRef, pluginId)!;\n allDeps.push(target.then(impl => [name, impl]));\n }\n\n result = implementation.factoryFunc\n .then(func =>\n Promise.all(allDeps).then(entries =>\n func(Object.fromEntries(entries)),\n ),\n )\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' for '${pluginId}' because the factory function threw an error, ${cause}`,\n );\n });\n implementation.byPlugin.set(pluginId, result);\n }\n\n return result;\n });\n }\n}\n","/*\n * Copyright 2022 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 { ServiceFactory, BackendFeature } from '@backstage/backend-plugin-api';\nimport { BackendInitializer } from './BackendInitializer';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { Backend } from './types';\n\nexport class BackstageBackend implements Backend {\n #services: ServiceRegistry;\n #initializer: BackendInitializer;\n\n constructor(apiFactories: ServiceFactory[]) {\n this.#services = new ServiceRegistry(apiFactories);\n this.#initializer = new BackendInitializer(this.#services);\n }\n\n add(feature: BackendFeature): void {\n this.#initializer.add(feature);\n }\n\n async start(): Promise<void> {\n await this.#initializer.start();\n }\n\n async stop(): Promise<void> {\n await this.#initializer.stop();\n }\n}\n","/*\n * Copyright 2022 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 ServiceFactory,\n BackendFeature,\n ExtensionPoint,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackstageBackend } from './BackstageBackend';\n\n/**\n * @public\n */\nexport interface Backend {\n add(feature: BackendFeature): void;\n start(): Promise<void>;\n stop(): Promise<void>;\n}\n\nexport interface BackendRegisterInit {\n id: string;\n consumes: Set<ServiceOrExtensionPoint>;\n provides: Set<ServiceOrExtensionPoint>;\n deps: { [name: string]: ServiceOrExtensionPoint };\n init: (deps: { [name: string]: unknown }) => Promise<void>;\n}\n\n/**\n * @public\n */\nexport interface CreateSpecializedBackendOptions {\n services: (ServiceFactory | (() => ServiceFactory))[];\n}\n\nexport interface ServiceHolder {\n get<T>(api: ServiceRef<T>, pluginId: string): Promise<T> | undefined;\n}\n\n/**\n * @internal\n */\nexport interface EnumerableServiceHolder extends ServiceHolder {\n getServiceRefs(): ServiceRef<unknown>[];\n}\n\n/**\n * @public\n */\nexport function createSpecializedBackend(\n options: CreateSpecializedBackendOptions,\n): Backend {\n return new BackstageBackend(\n options.services.map(s => (typeof s === 'function' ? s() : s)),\n );\n}\n\n/**\n * @public\n */\nexport type ServiceOrExtensionPoint<T = unknown> =\n | ExtensionPoint<T>\n | ServiceRef<T>;\n","/*\n * Copyright 2022 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 { CacheManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const cacheFactory = createServiceFactory({\n service: coreServices.cache,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const cacheManager = CacheManager.fromConfig(config);\n return async ({ plugin }) => {\n return cacheManager.forPlugin(plugin.getId());\n };\n },\n});\n","/*\n * Copyright 2022 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 { loadBackendConfig } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const configFactory = createServiceFactory({\n service: coreServices.config,\n deps: {\n logger: coreServices.rootLogger,\n },\n async factory({ logger }) {\n const config = await loadBackendConfig({\n argv: process.argv,\n logger: loggerToWinstonLogger(logger),\n });\n return config;\n },\n});\n","/*\n * Copyright 2022 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 { DatabaseManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const databaseFactory = createServiceFactory({\n service: coreServices.database,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const databaseManager = DatabaseManager.fromConfig(config);\n return async ({ plugin }) => {\n return databaseManager.forPlugin(plugin.getId());\n };\n },\n});\n","/*\n * Copyright 2022 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 { SingleHostDiscovery } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const discoveryFactory = createServiceFactory({\n service: coreServices.discovery,\n deps: {\n config: coreServices.config,\n },\n async factory({ config }) {\n const discovery = SingleHostDiscovery.fromConfig(config);\n return async () => {\n return discovery;\n };\n },\n});\n","/*\n * Copyright 2022 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 createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const loggerFactory = createServiceFactory({\n service: coreServices.logger,\n deps: {\n rootLogger: coreServices.rootLogger,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ rootLogger }) {\n return async ({ plugin }) => {\n return rootLogger.child({ pluginId: plugin.getId() });\n };\n },\n});\n","/*\n * Copyright 2022 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 { createRootLogger } from '@backstage/backend-common';\nimport {\n createServiceFactory,\n LoggerService,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { LogMeta } from '@backstage/backend-plugin-api';\nimport { Logger as WinstonLogger } from 'winston';\n\nclass BackstageLogger implements LoggerService {\n static fromWinston(logger: WinstonLogger): BackstageLogger {\n return new BackstageLogger(logger);\n }\n\n private constructor(private readonly winston: WinstonLogger) {}\n\n error(message: string, meta?: LogMeta): void {\n this.winston.error(message, meta);\n }\n\n warn(message: string, meta?: LogMeta): void {\n this.winston.warn(message, meta);\n }\n\n info(message: string, meta?: LogMeta): void {\n this.winston.info(message, meta);\n }\n\n debug(message: string, meta?: LogMeta): void {\n this.winston.debug(message, meta);\n }\n\n child(meta: LogMeta): LoggerService {\n return new BackstageLogger(this.winston.child(meta));\n }\n}\n\n/** @public */\nexport const rootLoggerFactory = createServiceFactory({\n service: coreServices.rootLogger,\n deps: {},\n async factory() {\n return BackstageLogger.fromWinston(createRootLogger());\n },\n});\n","/*\n * Copyright 2022 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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { ServerPermissionClient } from '@backstage/plugin-permission-node';\n\n/** @public */\nexport const permissionsFactory = createServiceFactory({\n service: coreServices.permissions,\n deps: {\n config: coreServices.config,\n discovery: coreServices.discovery,\n tokenManager: coreServices.tokenManager,\n },\n async factory({ config }) {\n return async ({ discovery, tokenManager }) => {\n return ServerPermissionClient.fromConfig(config, {\n discovery,\n tokenManager,\n });\n };\n },\n});\n","/*\n * Copyright 2022 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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduler } from '@backstage/backend-tasks';\n\n/** @public */\nexport const schedulerFactory = createServiceFactory({\n service: coreServices.scheduler,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const taskScheduler = TaskScheduler.fromConfig(config);\n return async ({ plugin }) => {\n return taskScheduler.forPlugin(plugin.getId());\n };\n },\n});\n","/*\n * Copyright 2022 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 coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\nimport { ServerTokenManager } from '@backstage/backend-common';\n\n/** @public */\nexport const tokenManagerFactory = createServiceFactory({\n service: coreServices.tokenManager,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return ServerTokenManager.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n });\n };\n },\n});\n","/*\n * Copyright 2022 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 { UrlReaders } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n loggerToWinstonLogger,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const urlReaderFactory = createServiceFactory({\n service: coreServices.urlReader,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return UrlReaders.default({\n config,\n logger: loggerToWinstonLogger(logger),\n });\n };\n },\n});\n","/*\n * Copyright 2022 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 createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport Router from 'express-promise-router';\nimport { Handler } from 'express';\nimport { createServiceBuilder } from '@backstage/backend-common';\n\n/**\n * @public\n */\nexport type HttpRouterFactoryOptions = {\n /**\n * The plugin ID used for the index route. Defaults to 'app'\n */\n indexPlugin?: string;\n};\n\n/** @public */\nexport const httpRouterFactory = createServiceFactory({\n service: coreServices.httpRouter,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }, options?: HttpRouterFactoryOptions) {\n const defaultPluginId = options?.indexPlugin ?? 'app';\n\n const apiRouter = Router();\n const rootRouter = Router();\n\n const service = createServiceBuilder(module)\n .loadConfig(config)\n .addRouter('/api', apiRouter)\n .addRouter('', rootRouter);\n\n await service.start();\n\n return async ({ plugin }) => {\n const pluginId = plugin.getId();\n return {\n use(handler: Handler) {\n if (pluginId === defaultPluginId) {\n rootRouter.use(handler);\n } else {\n apiRouter.use(`/${pluginId}`, handler);\n }\n },\n };\n };\n },\n});\n"],"names":["__privateAdd","__privateGet","__privateSet","createServiceFactory","coreServices","loggerToWinstonLogger","__privateMethod","stringifyError","CacheManager","loadBackendConfig","DatabaseManager","SingleHostDiscovery","createRootLogger","ServerPermissionClient","TaskScheduler","ServerTokenManager","UrlReaders","Router","createServiceBuilder"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,SAAA,EAAA,cAAA,CAAA;AAwBA,MAAM,SAAY,GAAA,CAAC,SAAW,EAAA,QAAA,EAAU,YAAY,CAAA,CAAA;AAC7C,MAAM,oBAAqB,CAAA;AAAA,EAChC,YAA6B,MAAgB,EAAA;AAAhB,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA,CAAA;AAI7B,IAAYA,cAAA,CAAA,IAAA,EAAA,SAAA,EAAA,KAAA,CAAA,CAAA;AACZ,IAAAA,cAAA,CAAA,IAAA,EAAA,cAAA,EACE,EAAC,CAAA,CAAA;AALD,IAAU,SAAA,CAAA,GAAA,CAAI,YAAU,OAAQ,CAAA,EAAA,CAAG,QAAQ,MAAM,IAAA,CAAK,QAAS,EAAC,CAAC,CAAA,CAAA;AAAA,GACnE;AAAA,EAMA,gBACE,OACM,EAAA;AACN,IAAKC,cAAA,CAAA,IAAA,EAAA,cAAA,CAAA,CAAe,KAAK,OAAO,CAAA,CAAA;AAAA,GAClC;AAAA,EAEA,MAAM,QAA0B,GAAA;AAC9B,IAAA,IAAIA,qBAAK,SAAW,CAAA,EAAA;AAClB,MAAA,OAAA;AAAA,KACF;AACA,IAAAC,cAAA,CAAA,IAAA,EAAK,SAAY,EAAA,IAAA,CAAA,CAAA;AAEjB,IAAA,IAAA,CAAK,MAAO,CAAA,IAAA,CAAK,CAAW,QAAA,EAAAD,cAAA,CAAA,IAAA,EAAK,gBAAe,MAA0B,CAAA,kBAAA,CAAA,CAAA,CAAA;AAC1E,IAAA,MAAM,OAAQ,CAAA,GAAA;AAAA,MACZA,qBAAK,cAAe,CAAA,CAAA,GAAA;AAAA,QAAI,CAAA,IAAA,KACtB,OAAQ,CAAA,O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U,OAAoC,EAAA;AAzChE,IAAA,IAAA,EAAA,CAAA;AA0CI,IAAM,MAAA,eAAA,GAAA,CAAkB,EAAS,GAAA,OAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,OAAA,CAAA,WAAA,KAAT,IAAwB,GAAA,EAAA,GAAA,KAAA,CAAA;AAEhD,IAAA,MAAM,YAAYa,0BAAO,EAAA,CAAA;AACzB,IAAA,MAAM,aAAaA,0BAAO,EAAA,CAAA;AAE1B,IAAA,MAAM,OAAU,GAAAC,kCAAA,CAAqB,MAAM,CAAA,CACxC,UAAW,CAAA,MAAM,CACjB,CAAA,SAAA,CAAU,MAAQ,EAAA,SAAS,CAC3B,CAAA,SAAA,CAAU,IAAI,UAAU,CAAA,CAAA;AAE3B,IAAA,MAAM,QAAQ,KAAM,EAAA,CAAA;AAEpB,IAAO,OAAA,OAAO,EAAE,MAAA,EAAa,KAAA;AAC3B,MAAM,MAAA,QAAA,GAAW,OAAO,KAAM,EAAA,CAAA;AAC9B,MAAO,OAAA;AAAA,QACL,IAAI,OAAkB,EAAA;AACpB,UAAA,IAAI,aAAa,eAAiB,EAAA;AAChC,YAAA,UAAA,CAAW,IAAI,OAAO,CAAA,CAAA;AAAA,WACjB,MAAA;AACL,YAAU,SAAA,CAAA,GAAA,CAAI,CAAI,CAAA,EAAA,QAAA,CAAA,CAAA,EAAY,OAAO,CAAA,CAAA;AAAA,WACvC;AAAA,SACF;AAAA,OACF,CAAA;AAAA,KACF,CAAA;AAAA,GACF;AACF,CAAC;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/http/config.ts","../src/http/getGeneratedCertificate.ts","../src/http/createHttpServer.ts","../src/http/readHelmetOptions.ts","../src/http/readCorsOptions.ts","../src/http/MiddlewareFactory.ts","../src/services/implementations/rootLifecycleService.ts","../src/wiring/BackendInitializer.ts","../src/wiring/ServiceRegistry.ts","../src/wiring/BackstageBackend.ts","../src/wiring/createSpecializedBackend.ts","../src/services/implementations/httpRouter/httpRouterFactory.ts","../src/services/implementations/rootHttpRouter/RestrictedIndexedRouter.ts","../src/services/implementations/rootHttpRouter/rootHttpRouterFactory.ts","../src/services/implementations/cacheService.ts","../src/services/implementations/configService.ts","../src/services/implementations/databaseService.ts","../src/services/implementations/discoveryService.ts","../src/services/implementations/loggerService.ts","../src/services/implementations/rootLoggerService.ts","../src/services/implementations/permissionsService.ts","../src/services/implementations/schedulerService.ts","../src/services/implementations/tokenManagerService.ts","../src/services/implementations/urlReaderService.ts","../src/services/implementations/lifecycleService.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 { Config } from '@backstage/config';\nimport { HttpServerOptions } from './types';\n\nconst DEFAULT_PORT = 7007;\nconst DEFAULT_HOST = '';\n\n/**\n * Reads {@link HttpServerOptions} from a {@link @backstage/config#Config} object.\n *\n * @public\n * @remarks\n *\n * The provided configuration object should contain the `listen` and\n * additional keys directly.\n *\n * @example\n * ```ts\n * const opts = readHttpServerOptions(config.getConfig('backend'));\n * ```\n */\nexport function readHttpServerOptions(config?: Config): HttpServerOptions {\n return {\n listen: readHttpListenOptions(config),\n https: readHttpsOptions(config),\n };\n}\n\nfunction readHttpListenOptions(config?: Config): HttpServerOptions['listen'] {\n const listen = config?.getOptional('listen');\n if (typeof listen === 'string') {\n const parts = String(listen).split(':');\n const port = parseInt(parts[parts.length - 1], 10);\n if (!isNaN(port)) {\n if (parts.length === 1) {\n return { port, host: DEFAULT_HOST };\n }\n if (parts.length === 2) {\n return { host: parts[0], port };\n }\n }\n throw new Error(\n `Unable to parse listen address ${listen}, expected <port> or <host>:<port>`,\n );\n }\n\n // Workaround to allow empty string\n const host = config?.getOptional('listen.host') ?? DEFAULT_HOST;\n if (typeof host !== 'string') {\n config?.getOptionalString('listen.host'); // will throw\n throw new Error('unreachable');\n }\n\n return {\n port: config?.getOptionalNumber('listen.port') ?? DEFAULT_PORT,\n host,\n };\n}\n\nfunction readHttpsOptions(config?: Config): HttpServerOptions['https'] {\n const https = config?.getOptional('https');\n if (https === true) {\n const baseUrl = config!.getString('baseUrl');\n let hostname;\n try {\n hostname = new URL(baseUrl).hostname;\n } catch (error) {\n throw new Error(`Invalid baseUrl \"${baseUrl}\"`);\n }\n\n return { certificate: { type: 'generated', hostname } };\n }\n\n const cc = config?.getOptionalConfig('https');\n if (!cc) {\n return undefined;\n }\n\n return {\n certificate: {\n type: 'plain',\n cert: cc.getString('certificate.cert'),\n key: cc.getString('certificate.key'),\n },\n };\n}\n","/*\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 fs from 'fs-extra';\nimport { resolve as resolvePath, dirname } from 'path';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport forge from 'node-forge';\n\nconst FIVE_DAYS_IN_MS = 5 * 24 * 60 * 60 * 1000;\n\nconst IP_HOSTNAME_REGEX = /:|^\\d+\\.\\d+\\.\\d+\\.\\d+$/;\n\nexport async function getGeneratedCertificate(\n hostname: string,\n logger: LoggerService,\n) {\n const hasModules = await fs.pathExists('node_modules');\n let certPath;\n if (hasModules) {\n certPath = resolvePath(\n 'node_modules/.cache/backstage-backend/dev-cert.pem',\n );\n await fs.ensureDir(dirname(certPath));\n } else {\n certPath = resolvePath('.dev-cert.pem');\n }\n\n if (await fs.pathExists(certPath)) {\n try {\n const cert = await fs.readFile(certPath);\n\n const crt = forge.pki.certificateFromPem(cert.toString());\n const remainingMs = crt.validity.notAfter.getTime() - Date.now();\n if (remainingMs > FIVE_DAYS_IN_MS) {\n logger.info('Using existing self-signed certificate');\n return {\n key: cert,\n cert,\n };\n }\n } catch (error) {\n logger.warn(`Unable to use existing self-signed certificate, ${error}`);\n }\n }\n\n logger.info('Generating new self-signed certificate');\n const newCert = await generateCertificate(hostname);\n await fs.writeFile(certPath, newCert.cert + newCert.key, 'utf8');\n return newCert;\n}\n\nasync function generateCertificate(hostname: string) {\n const attributes = [\n {\n name: 'commonName',\n value: 'dev-cert',\n },\n ];\n\n const sans = [\n {\n type: 2, // DNS\n value: 'localhost',\n },\n {\n type: 2,\n value: 'localhost.localdomain',\n },\n {\n type: 2,\n value: '[::1]',\n },\n {\n type: 7, // IP\n ip: '127.0.0.1',\n },\n {\n type: 7,\n ip: 'fe80::1',\n },\n ];\n\n // Add hostname from backend.baseUrl if it doesn't already exist in our list of SANs\n if (!sans.find(({ value, ip }) => value === hostname || ip === hostname)) {\n sans.push(\n IP_HOSTNAME_REGEX.test(hostname)\n ? {\n type: 7,\n ip: hostname,\n }\n : {\n type: 2,\n value: hostname,\n },\n );\n }\n\n const params = {\n algorithm: 'sha256',\n keySize: 2048,\n days: 30,\n extensions: [\n {\n name: 'keyUsage',\n keyCertSign: true,\n digitalSignature: true,\n nonRepudiation: true,\n keyEncipherment: true,\n dataEncipherment: true,\n },\n {\n name: 'extKeyUsage',\n serverAuth: true,\n clientAuth: true,\n codeSigning: true,\n timeStamping: true,\n },\n {\n name: 'subjectAltName',\n altNames: sans,\n },\n ],\n };\n\n return new Promise<{ key: string; cert: string }>((resolve, reject) =>\n require('selfsigned').generate(\n attributes,\n params,\n (err: Error, bundle: { private: string; cert: string }) => {\n if (err) {\n reject(err);\n } else {\n resolve({ key: bundle.private, cert: bundle.cert });\n }\n },\n ),\n );\n}\n","/*\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 * as http from 'http';\nimport * as https from 'https';\nimport stoppableServer from 'stoppable';\nimport { RequestListener } from 'http';\nimport { LoggerService } from '@backstage/backend-plugin-api';\nimport { HttpServerOptions, ExtendedHttpServer } from './types';\nimport { getGeneratedCertificate } from './getGeneratedCertificate';\n\n/**\n * Creates a Node.js HTTP or HTTPS server instance.\n *\n * @public\n */\nexport async function createHttpServer(\n listener: RequestListener,\n options: HttpServerOptions,\n deps: { logger: LoggerService },\n): Promise<ExtendedHttpServer> {\n const server = await createServer(listener, options, deps);\n\n const stopper = stoppableServer(server, 0);\n // The stopper here is actually the server itself, so if we try\n // to call stopper.stop() down in the stop implementation, we'll\n // be calling ourselves.\n const stopServer = stopper.stop.bind(stopper);\n\n return Object.assign(server, {\n start() {\n return new Promise<void>((resolve, reject) => {\n const handleStartupError = (error: Error) => {\n server.close();\n reject(error);\n };\n\n server.on('error', handleStartupError);\n\n const { host, port } = options.listen;\n server.listen(port, host, () => {\n server.off('error', handleStartupError);\n deps.logger.info(`Listening on ${host}:${port}`);\n resolve();\n });\n });\n },\n\n stop() {\n return new Promise<void>((resolve, reject) => {\n stopServer((error?: Error) => {\n if (error) {\n reject(error);\n } else {\n resolve();\n }\n });\n });\n },\n\n port() {\n const address = server.address();\n if (typeof address === 'string' || address === null) {\n throw new Error(`Unexpected server address '${address}'`);\n }\n return address.port;\n },\n });\n}\n\nasync function createServer(\n listener: RequestListener,\n options: HttpServerOptions,\n deps: { logger: LoggerService },\n): Promise<http.Server> {\n if (options.https) {\n const { certificate } = options.https;\n if (certificate.type === 'generated') {\n const credentials = await getGeneratedCertificate(\n certificate.hostname,\n deps.logger,\n );\n return https.createServer(credentials, listener);\n }\n return https.createServer(certificate, listener);\n }\n\n return http.createServer(listener);\n}\n","/*\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 { Config } from '@backstage/config';\nimport helmet from 'helmet';\nimport { HelmetOptions } from 'helmet';\nimport { ContentSecurityPolicyOptions } from 'helmet/dist/types/middlewares/content-security-policy';\n\n/**\n * Attempts to read Helmet options from the backend configuration object.\n *\n * @public\n * @param config - The backend configuration object.\n * @returns A Helmet options object, or undefined if no Helmet configuration is present.\n *\n * @example\n * ```ts\n * const helmetOptions = readHelmetOptions(config.getConfig('backend'));\n * ```\n */\nexport function readHelmetOptions(config?: Config): HelmetOptions {\n const cspOptions = readCspDirectives(config);\n return {\n contentSecurityPolicy: {\n useDefaults: false,\n directives: applyCspDirectives(cspOptions),\n },\n // These are all disabled in order to maintain backwards compatibility\n // when bumping helmet v5. We can't enable these by default because\n // there is no way for users to configure them.\n // TODO(Rugvip): We should give control of this setup to consumers\n crossOriginEmbedderPolicy: false,\n crossOriginOpenerPolicy: false,\n crossOriginResourcePolicy: false,\n originAgentCluster: false,\n };\n}\n\ntype CspDirectives = Record<string, string[] | false> | undefined;\n\n/**\n * Attempts to read a CSP directives from the backend configuration object.\n *\n * @example\n * ```yaml\n * backend:\n * csp:\n * connect-src: [\"'self'\", 'http:', 'https:']\n * upgrade-insecure-requests: false\n * ```\n */\nfunction readCspDirectives(config?: Config): CspDirectives {\n const cc = config?.getOptionalConfig('csp');\n if (!cc) {\n return undefined;\n }\n\n const result: Record<string, string[] | false> = {};\n for (const key of cc.keys()) {\n if (cc.get(key) === false) {\n result[key] = false;\n } else {\n result[key] = cc.getStringArray(key);\n }\n }\n\n return result;\n}\n\nexport function applyCspDirectives(\n directives: CspDirectives,\n): ContentSecurityPolicyOptions['directives'] {\n const result: ContentSecurityPolicyOptions['directives'] =\n helmet.contentSecurityPolicy.getDefaultDirectives();\n\n // TODO(Rugvip): We currently use non-precompiled AJV for validation in the frontend, which uses eval.\n // It should be replaced by any other solution that doesn't require unsafe-eval.\n result['script-src'] = [\"'self'\", \"'unsafe-eval'\"];\n\n // TODO(Rugvip): This is removed so that we maintained backwards compatibility\n // when bumping to helmet v5, we could remove this as well as\n // skip setting `useDefaults: false` in the future.\n delete result['form-action'];\n\n if (directives) {\n for (const [key, value] of Object.entries(directives)) {\n if (value === false) {\n delete result[key];\n } else {\n result[key] = value;\n }\n }\n }\n\n return result;\n}\n","/*\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 { Config } from '@backstage/config';\nimport { CorsOptions } from 'cors';\nimport { Minimatch } from 'minimatch';\n\n/**\n * Attempts to read a CORS options object from the backend configuration object.\n *\n * @public\n * @param config - The backend configuration object.\n * @returns A CORS options object, or undefined if no cors configuration is present.\n *\n * @example\n * ```ts\n * const corsOptions = readCorsOptions(config.getConfig('backend'));\n * ```\n */\nexport function readCorsOptions(config?: Config): CorsOptions {\n const cc = config?.getOptionalConfig('cors');\n if (!cc) {\n return { origin: false }; // Disable CORS\n }\n\n return {\n origin: createCorsOriginMatcher(readStringArray(cc, 'origin')),\n methods: readStringArray(cc, 'methods'),\n allowedHeaders: readStringArray(cc, 'allowedHeaders'),\n exposedHeaders: readStringArray(cc, 'exposedHeaders'),\n credentials: cc.getOptionalBoolean('credentials'),\n maxAge: cc.getOptionalNumber('maxAge'),\n preflightContinue: cc.getOptionalBoolean('preflightContinue'),\n optionsSuccessStatus: cc.getOptionalNumber('optionsSuccessStatus'),\n };\n}\n\nfunction readStringArray(config: Config, key: string): string[] | undefined {\n const value = config.getOptional(key);\n if (typeof value === 'string') {\n return [value];\n } else if (!value) {\n return undefined;\n }\n return config.getStringArray(key);\n}\n\nfunction createCorsOriginMatcher(allowedOriginPatterns: string[] | undefined) {\n if (!allowedOriginPatterns) {\n return undefined;\n }\n\n const allowedOriginMatchers = allowedOriginPatterns.map(\n pattern => new Minimatch(pattern, { nocase: true, noglobstar: true }),\n );\n\n return (\n origin: string | undefined,\n callback: (\n err: Error | null,\n origin: boolean | string | RegExp | (boolean | string | RegExp)[],\n ) => void,\n ) => {\n return callback(\n null,\n allowedOriginMatchers.some(pattern => pattern.match(origin ?? '')),\n );\n };\n}\n","/*\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 { ConfigService, LoggerService } from '@backstage/backend-plugin-api';\nimport {\n Request,\n Response,\n ErrorRequestHandler,\n NextFunction,\n RequestHandler,\n} from 'express';\nimport cors from 'cors';\nimport helmet from 'helmet';\nimport morgan from 'morgan';\nimport compression from 'compression';\nimport { readHelmetOptions } from './readHelmetOptions';\nimport { readCorsOptions } from './readCorsOptions';\nimport {\n AuthenticationError,\n ConflictError,\n ErrorResponseBody,\n InputError,\n NotAllowedError,\n NotFoundError,\n NotModifiedError,\n serializeError,\n} from '@backstage/errors';\n\n/**\n * Options used to create a {@link MiddlewareFactory}.\n *\n * @public\n */\nexport interface MiddlewareFactoryOptions {\n config: ConfigService;\n logger: LoggerService;\n}\n\n/**\n * Options passed to the {@link MiddlewareFactory.error} middleware.\n *\n * @public\n */\nexport interface MiddlewareFactoryErrorOptions {\n /**\n * Whether error response bodies should show error stack traces or not.\n *\n * If not specified, by default shows stack traces only in development mode.\n */\n showStackTraces?: boolean;\n\n /**\n * Whether any 4xx errors should be logged or not.\n *\n * If not specified, default to only logging 5xx errors.\n */\n logAllErrors?: boolean;\n}\n\n/**\n * A utility to configure common middleware.\n *\n * @public\n */\nexport class MiddlewareFactory {\n #config: ConfigService;\n #logger: LoggerService;\n\n /**\n * Creates a new {@link MiddlewareFactory}.\n */\n static create(options: MiddlewareFactoryOptions) {\n return new MiddlewareFactory(options);\n }\n\n private constructor(options: MiddlewareFactoryOptions) {\n this.#config = options.config;\n this.#logger = options.logger;\n }\n\n /**\n * Returns a middleware that unconditionally produces a 404 error response.\n *\n * @remarks\n *\n * Typically you want to place this middleware at the end of the chain, such\n * that it's the last one attempted after no other routes matched.\n *\n * @returns An Express request handler\n */\n notFound(): RequestHandler {\n return (_req: Request, res: Response) => {\n res.status(404).end();\n };\n }\n\n /**\n * Returns the compression middleware.\n *\n * @remarks\n *\n * The middleware will attempt to compress response bodies for all requests\n * that traverse through the middleware.\n */\n compression(): RequestHandler {\n return compression();\n }\n\n /**\n * Returns a request logging middleware.\n *\n * @remarks\n *\n * Typically you want to place this middleware at the start of the chain, such\n * that it always logs requests whether they are \"caught\" by handlers farther\n * down or not.\n *\n * @returns An Express request handler\n */\n logging(): RequestHandler {\n const logger = this.#logger.child({\n type: 'incomingRequest',\n });\n\n return morgan('combined', {\n stream: {\n write(message: string) {\n logger.info(message.trimEnd());\n },\n },\n });\n }\n\n /**\n * Returns a middleware that implements the helmet library.\n *\n * @remarks\n *\n * This middleware applies security policies to incoming requests and outgoing\n * responses. It is configured using config keys such as `backend.csp`.\n *\n * @see {@link https://helmetjs.github.io/}\n *\n * @returns An Express request handler\n */\n helmet(): RequestHandler {\n return helmet(readHelmetOptions(this.#config.getOptionalConfig('backend')));\n }\n\n /**\n * Returns a middleware that implements the cors library.\n *\n * @remarks\n *\n * This middleware handles CORS. It is configured using the config key\n * `backend.cors`.\n *\n * @see {@link https://github.com/expressjs/cors}\n *\n * @returns An Express request handler\n */\n cors(): RequestHandler {\n return cors(readCorsOptions(this.#config.getOptionalConfig('backend')));\n }\n\n /**\n * Express middleware to handle errors during request processing.\n *\n * @remarks\n *\n * This is commonly the very last middleware in the chain.\n *\n * Its primary purpose is not to do translation of business logic exceptions,\n * but rather to be a global catch-all for uncaught \"fatal\" errors that are\n * expected to result in a 500 error. However, it also does handle some common\n * error types (such as http-error exceptions, and the well-known error types\n * in the `@backstage/errors` package) and returns the enclosed status code\n * accordingly.\n *\n * It will also produce a response body with a serialized form of the error,\n * unless a previous handler already did send a body. See\n * {@link @backstage/errors#ErrorResponseBody} for the response shape used.\n *\n * @returns An Express error request handler\n */\n error(options: MiddlewareFactoryErrorOptions = {}): ErrorRequestHandler {\n const showStackTraces =\n options.showStackTraces ?? process.env.NODE_ENV === 'development';\n\n const logger = this.#logger.child({\n type: 'errorHandler',\n });\n\n return (error: Error, req: Request, res: Response, next: NextFunction) => {\n const statusCode = getStatusCode(error);\n if (options.logAllErrors || statusCode >= 500) {\n logger.error(`Request failed with status ${statusCode}`, error);\n }\n\n if (res.headersSent) {\n // If the headers have already been sent, do not send the response again\n // as this will throw an error in the backend.\n next(error);\n return;\n }\n\n const body: ErrorResponseBody = {\n error: serializeError(error, { includeStack: showStackTraces }),\n request: { method: req.method, url: req.url },\n response: { statusCode },\n };\n\n res.status(statusCode).json(body);\n };\n }\n}\n\nfunction getStatusCode(error: Error): number {\n // Look for common http library status codes\n const knownStatusCodeFields = ['statusCode', 'status'];\n for (const field of knownStatusCodeFields) {\n const statusCode = (error as any)[field];\n if (\n typeof statusCode === 'number' &&\n (statusCode | 0) === statusCode && // is whole integer\n statusCode >= 100 &&\n statusCode <= 599\n ) {\n return statusCode;\n }\n }\n\n // Handle well-known error types\n switch (error.name) {\n case NotModifiedError.name:\n return 304;\n case InputError.name:\n return 400;\n case AuthenticationError.name:\n return 401;\n case NotAllowedError.name:\n return 403;\n case NotFoundError.name:\n return 404;\n case ConflictError.name:\n return 409;\n default:\n break;\n }\n\n // Fall back to internal server error\n return 500;\n}\n","/*\n * Copyright 2022 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 createServiceFactory,\n coreServices,\n LifecycleServiceShutdownHook,\n RootLifecycleService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\n\nconst CALLBACKS = ['SIGTERM', 'SIGINT', 'beforeExit'];\nexport class BackendLifecycleImpl implements RootLifecycleService {\n constructor(private readonly logger: LoggerService) {\n CALLBACKS.map(signal => process.on(signal, () => this.shutdown()));\n }\n\n #isCalled = false;\n #shutdownTasks: Array<LifecycleServiceShutdownHook> = [];\n\n addShutdownHook(options: LifecycleServiceShutdownHook): void {\n this.#shutdownTasks.push(options);\n }\n\n async shutdown(): Promise<void> {\n if (this.#isCalled) {\n return;\n }\n this.#isCalled = true;\n\n this.logger.info(`Running ${this.#shutdownTasks.length} shutdown tasks...`);\n await Promise.all(\n this.#shutdownTasks.map(async hook => {\n const { logger = this.logger } = hook;\n try {\n await hook.fn();\n logger.info(`Shutdown hook succeeded`);\n } catch (error) {\n logger.error(`Shutdown hook failed, ${error}`);\n }\n }),\n );\n }\n}\n\n/**\n * Allows plugins to register shutdown hooks that are run when the process is about to exit.\n * @public */\nexport const rootLifecycleFactory = createServiceFactory({\n service: coreServices.rootLifecycle,\n deps: {\n logger: coreServices.rootLogger,\n },\n async factory({ logger }) {\n return new BackendLifecycleImpl(logger);\n },\n});\n","/*\n * Copyright 2022 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 BackendFeature,\n ExtensionPoint,\n coreServices,\n ServiceRef,\n} from '@backstage/backend-plugin-api';\nimport { BackendLifecycleImpl } from '../services/implementations/rootLifecycleService';\nimport {\n BackendRegisterInit,\n EnumerableServiceHolder,\n ServiceOrExtensionPoint,\n} from './types';\n\nexport class BackendInitializer {\n #started = false;\n #features = new Map<BackendFeature, unknown>();\n #registerInits = new Array<BackendRegisterInit>();\n #extensionPoints = new Map<ExtensionPoint<unknown>, unknown>();\n #serviceHolder: EnumerableServiceHolder;\n\n constructor(serviceHolder: EnumerableServiceHolder) {\n this.#serviceHolder = serviceHolder;\n }\n\n async #getInitDeps(\n deps: { [name: string]: ServiceOrExtensionPoint },\n pluginId: string,\n ) {\n const result = new Map<string, unknown>();\n const missingRefs = new Set<ServiceOrExtensionPoint>();\n\n for (const [name, ref] of Object.entries(deps)) {\n const extensionPoint = this.#extensionPoints.get(\n ref as ExtensionPoint<unknown>,\n );\n if (extensionPoint) {\n result.set(name, extensionPoint);\n } else {\n const impl = await this.#serviceHolder.get(\n ref as ServiceRef<unknown>,\n pluginId,\n );\n if (impl) {\n result.set(name, impl);\n } else {\n missingRefs.add(ref);\n }\n }\n }\n\n if (missingRefs.size > 0) {\n const missing = Array.from(missingRefs).join(', ');\n throw new Error(\n `No extension point or service available for the following ref(s): ${missing}`,\n );\n }\n\n return Object.fromEntries(result);\n }\n\n add<TOptions>(feature: BackendFeature, options?: TOptions) {\n if (this.#started) {\n throw new Error('feature can not be added after the backend has started');\n }\n this.#features.set(feature, options);\n }\n\n async start(): Promise<void> {\n if (this.#started) {\n throw new Error('Backend has already started');\n }\n this.#started = true;\n\n // Initialize all root scoped services\n for (const ref of this.#serviceHolder.getServiceRefs()) {\n if (ref.scope === 'root') {\n await this.#serviceHolder.get(ref, 'root');\n }\n }\n\n // Initialize all features\n for (const [feature] of this.#features) {\n const provides = new Set<ExtensionPoint<unknown>>();\n\n let registerInit: BackendRegisterInit | undefined = undefined;\n\n feature.register({\n registerExtensionPoint: (extensionPointRef, impl) => {\n if (registerInit) {\n throw new Error('registerExtensionPoint called after registerInit');\n }\n if (this.#extensionPoints.has(extensionPointRef)) {\n throw new Error(`API ${extensionPointRef.id} already registered`);\n }\n this.#extensionPoints.set(extensionPointRef, impl);\n provides.add(extensionPointRef);\n },\n registerInit: registerOptions => {\n if (registerInit) {\n throw new Error('registerInit must only be called once');\n }\n registerInit = {\n id: feature.id,\n provides,\n consumes: new Set(Object.values(registerOptions.deps)),\n deps: registerOptions.deps,\n init: registerOptions.init as BackendRegisterInit['init'],\n };\n },\n });\n\n if (!registerInit) {\n throw new Error(\n `registerInit was not called by register in ${feature.id}`,\n );\n }\n\n this.#registerInits.push(registerInit);\n }\n\n const orderedRegisterResults = this.#resolveInitOrder(this.#registerInits);\n\n for (const registerInit of orderedRegisterResults) {\n const deps = await this.#getInitDeps(registerInit.deps, registerInit.id);\n await registerInit.init(deps);\n }\n }\n\n #resolveInitOrder(registerInits: Array<BackendRegisterInit>) {\n let registerInitsToOrder = registerInits.slice();\n const orderedRegisterInits = new Array<BackendRegisterInit>();\n\n // TODO: Validate duplicates\n\n while (registerInitsToOrder.length > 0) {\n const toRemove = new Set<unknown>();\n\n for (const registerInit of registerInitsToOrder) {\n const unInitializedDependents = [];\n\n for (const provided of registerInit.provides) {\n if (\n registerInitsToOrder.some(\n init => init !== registerInit && init.consumes.has(provided),\n )\n ) {\n unInitializedDependents.push(provided);\n }\n }\n\n if (unInitializedDependents.length === 0) {\n orderedRegisterInits.push(registerInit);\n toRemove.add(registerInit);\n }\n }\n\n registerInitsToOrder = registerInitsToOrder.filter(r => !toRemove.has(r));\n }\n\n return orderedRegisterInits;\n }\n\n async stop(): Promise<void> {\n if (!this.#started) {\n return;\n }\n\n const lifecycleService = await this.#serviceHolder.get(\n coreServices.rootLifecycle,\n 'root',\n );\n\n // TODO(Rugvip): Find a better way to do this\n if (lifecycleService instanceof BackendLifecycleImpl) {\n await lifecycleService.shutdown();\n } else {\n throw new Error('Unexpected lifecycle service implementation');\n }\n }\n}\n","/*\n * Copyright 2022 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 ServiceFactory,\n ServiceRef,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { stringifyError } from '@backstage/errors';\nimport { EnumerableServiceHolder } from './types';\n/**\n * Keep in sync with `@backstage/backend-plugin-api/src/services/system/types.ts`\n * @internal\n */\nexport type InternalServiceRef<T> = ServiceRef<T> & {\n __defaultFactory?: (\n service: ServiceRef<T>,\n ) => Promise<ServiceFactory<T> | (() => ServiceFactory<T>)>;\n};\n\nexport class ServiceRegistry implements EnumerableServiceHolder {\n readonly #providedFactories: Map<string, ServiceFactory>;\n readonly #loadedDefaultFactories: Map<Function, Promise<ServiceFactory>>;\n readonly #implementations: Map<\n ServiceFactory,\n {\n factoryFunc: Promise<\n (deps: { [name in string]: unknown }) => Promise<unknown>\n >;\n byPlugin: Map<string, Promise<unknown>>;\n }\n >;\n\n constructor(factories: Array<ServiceFactory<unknown>>) {\n this.#providedFactories = new Map(factories.map(f => [f.service.id, f]));\n this.#loadedDefaultFactories = new Map();\n this.#implementations = new Map();\n }\n\n #resolveFactory(\n ref: ServiceRef<unknown>,\n pluginId: string,\n ): Promise<ServiceFactory> | undefined {\n // Special case handling of the plugin metadata service, generating a custom factory for it each time\n if (ref.id === coreServices.pluginMetadata.id) {\n return Promise.resolve({\n scope: 'plugin',\n service: coreServices.pluginMetadata,\n deps: {},\n factory: async () => async () => ({\n getId() {\n return pluginId;\n },\n }),\n });\n }\n\n let resolvedFactory: Promise<ServiceFactory> | ServiceFactory | undefined =\n this.#providedFactories.get(ref.id);\n const { __defaultFactory: defaultFactory } =\n ref as InternalServiceRef<unknown>;\n if (!resolvedFactory && !defaultFactory) {\n return undefined;\n }\n\n if (!resolvedFactory) {\n let loadedFactory = this.#loadedDefaultFactories.get(defaultFactory!);\n if (!loadedFactory) {\n loadedFactory = Promise.resolve()\n .then(() => defaultFactory!(ref))\n .then(f =>\n typeof f === 'function' ? f() : f,\n ) as Promise<ServiceFactory>;\n this.#loadedDefaultFactories.set(defaultFactory!, loadedFactory);\n }\n resolvedFactory = loadedFactory.catch(error => {\n throw new Error(\n `Failed to instantiate service '${\n ref.id\n }' because the default factory loader threw an error, ${stringifyError(\n error,\n )}`,\n );\n });\n }\n\n return Promise.resolve(resolvedFactory);\n }\n\n #separateMapForTheRootService = new Map<ServiceFactory, Promise<unknown>>();\n\n #checkForMissingDeps(factory: ServiceFactory, pluginId: string) {\n const missingDeps = Object.values(factory.deps).filter(ref => {\n if (ref.id === coreServices.pluginMetadata.id) {\n return false;\n }\n if (this.#providedFactories.get(ref.id)) {\n return false;\n }\n\n return !(ref as InternalServiceRef<unknown>).__defaultFactory;\n });\n\n if (missingDeps.length) {\n const missing = missingDeps.map(r => `'${r.id}'`).join(', ');\n throw new Error(\n `Failed to instantiate service '${factory.service.id}' for '${pluginId}' because the following dependent services are missing: ${missing}`,\n );\n }\n }\n\n getServiceRefs(): ServiceRef<unknown>[] {\n return Array.from(this.#providedFactories.values()).map(f => f.service);\n }\n\n get<T>(ref: ServiceRef<T>, pluginId: string): Promise<T> | undefined {\n return this.#resolveFactory(ref, pluginId)?.then(factory => {\n if (factory.scope === 'root') {\n let existing = this.#separateMapForTheRootService.get(factory);\n if (!existing) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope !== 'root') {\n throw new Error(\n `Failed to instantiate 'root' scoped service '${ref.id}' because it depends on '${serviceRef.scope}' scoped service '${serviceRef.id}'.`,\n );\n }\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n\n existing = Promise.all(rootDeps).then(entries =>\n factory.factory(Object.fromEntries(entries)),\n );\n this.#separateMapForTheRootService.set(factory, existing);\n }\n return existing as Promise<T>;\n }\n\n let implementation = this.#implementations.get(factory);\n if (!implementation) {\n this.#checkForMissingDeps(factory, pluginId);\n const rootDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n if (serviceRef.scope === 'root') {\n const target = this.get(serviceRef, pluginId)!;\n rootDeps.push(target.then(impl => [name, impl]));\n }\n }\n\n implementation = {\n factoryFunc: Promise.all(rootDeps)\n .then(entries => factory.factory(Object.fromEntries(entries)))\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' because the top-level factory function threw an error, ${cause}`,\n );\n }),\n byPlugin: new Map(),\n };\n\n this.#implementations.set(factory, implementation);\n }\n\n let result = implementation.byPlugin.get(pluginId) as Promise<any>;\n if (!result) {\n const allDeps = new Array<Promise<[name: string, impl: unknown]>>();\n\n for (const [name, serviceRef] of Object.entries(factory.deps)) {\n const target = this.get(serviceRef, pluginId)!;\n allDeps.push(target.then(impl => [name, impl]));\n }\n\n result = implementation.factoryFunc\n .then(func =>\n Promise.all(allDeps).then(entries =>\n func(Object.fromEntries(entries)),\n ),\n )\n .catch(error => {\n const cause = stringifyError(error);\n throw new Error(\n `Failed to instantiate service '${ref.id}' for '${pluginId}' because the factory function threw an error, ${cause}`,\n );\n });\n implementation.byPlugin.set(pluginId, result);\n }\n\n return result;\n });\n }\n}\n","/*\n * Copyright 2022 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 { ServiceFactory, BackendFeature } from '@backstage/backend-plugin-api';\nimport { BackendInitializer } from './BackendInitializer';\nimport { ServiceRegistry } from './ServiceRegistry';\nimport { Backend } from './types';\n\nexport class BackstageBackend implements Backend {\n #services: ServiceRegistry;\n #initializer: BackendInitializer;\n\n constructor(apiFactories: ServiceFactory[]) {\n this.#services = new ServiceRegistry(apiFactories);\n this.#initializer = new BackendInitializer(this.#services);\n }\n\n add(feature: BackendFeature): void {\n this.#initializer.add(feature);\n }\n\n async start(): Promise<void> {\n await this.#initializer.start();\n }\n\n async stop(): Promise<void> {\n await this.#initializer.stop();\n }\n}\n","/*\n * Copyright 2022 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 { coreServices } from '@backstage/backend-plugin-api';\nimport { BackstageBackend } from './BackstageBackend';\nimport { Backend, CreateSpecializedBackendOptions } from './types';\n\n/**\n * @public\n */\nexport function createSpecializedBackend(\n options: CreateSpecializedBackendOptions,\n): Backend {\n const services = options.services.map(sf =>\n typeof sf === 'function' ? sf() : sf,\n );\n\n const exists = new Set<string>();\n const duplicates = new Set<string>();\n for (const { service } of services) {\n if (exists.has(service.id)) {\n duplicates.add(service.id);\n } else {\n exists.add(service.id);\n }\n }\n if (duplicates.size > 0) {\n const ids = Array.from(duplicates).join(', ');\n throw new Error(`Duplicate service implementations provided for ${ids}`);\n }\n if (exists.has(coreServices.pluginMetadata.id)) {\n throw new Error(\n `The ${coreServices.pluginMetadata.id} service cannot be overridden`,\n );\n }\n\n return new BackstageBackend(services);\n}\n","/*\n * Copyright 2022 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 createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { Handler } from 'express';\n\n/**\n * @public\n */\nexport type HttpRouterFactoryOptions = {\n /**\n * A callback used to generate the path for each plugin, defaults to `/api/{pluginId}`.\n */\n getPath(pluginId: string): string;\n};\n\n/** @public */\nexport const httpRouterFactory = createServiceFactory({\n service: coreServices.httpRouter,\n deps: {\n plugin: coreServices.pluginMetadata,\n rootHttpRouter: coreServices.rootHttpRouter,\n },\n async factory({ rootHttpRouter }, options?: HttpRouterFactoryOptions) {\n const getPath = options?.getPath ?? (id => `/api/${id}`);\n\n return async ({ plugin }) => {\n const path = getPath(plugin.getId());\n return {\n use(handler: Handler) {\n rootHttpRouter.use(path, handler);\n },\n };\n };\n },\n});\n","/*\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 { RootHttpRouterService } from '@backstage/backend-plugin-api';\nimport { Handler, Router } from 'express';\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\/*$/, '/');\n}\n\nexport class RestrictedIndexedRouter implements RootHttpRouterService {\n #indexPath?: false | string;\n\n #router = Router();\n #namedRoutes = Router();\n #indexRouter = Router();\n #existingPaths = new Array<string>();\n\n constructor(indexPath?: false | string) {\n this.#indexPath = indexPath;\n this.#router.use(this.#namedRoutes);\n this.#router.use(this.#indexRouter);\n }\n\n use(path: string, handler: Handler) {\n if (path.match(/^[/\\s]*$/)) {\n throw new Error(`Root router path may not be empty`);\n }\n const conflictingPath = this.#findConflictingPath(path);\n if (conflictingPath) {\n throw new Error(\n `Path ${path} conflicts with the existing path ${conflictingPath}`,\n );\n }\n this.#existingPaths.push(path);\n this.#namedRoutes.use(path, handler);\n\n if (this.#indexPath === path) {\n this.#indexRouter.use(handler);\n }\n }\n\n handler(): Handler {\n return this.#router;\n }\n\n #findConflictingPath(newPath: string): string | undefined {\n const normalizedNewPath = normalizePath(newPath);\n for (const path of this.#existingPaths) {\n const normalizedPath = normalizePath(path);\n if (normalizedPath.startsWith(normalizedNewPath)) {\n return path;\n }\n if (normalizedNewPath.startsWith(normalizedPath)) {\n return path;\n }\n }\n return undefined;\n }\n}\n","/*\n * Copyright 2022 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 ConfigService,\n coreServices,\n createServiceFactory,\n LifecycleService,\n LoggerService,\n} from '@backstage/backend-plugin-api';\nimport express, { RequestHandler, Express } from 'express';\nimport {\n createHttpServer,\n MiddlewareFactory,\n readHttpServerOptions,\n} from '../../../http';\nimport { RestrictedIndexedRouter } from './RestrictedIndexedRouter';\n\n/**\n * @public\n */\nexport interface RootHttpRouterConfigureOptions {\n app: Express;\n middleware: MiddlewareFactory;\n routes: RequestHandler;\n config: ConfigService;\n logger: LoggerService;\n lifecycle: LifecycleService;\n}\n\n/**\n * @public\n */\nexport type RootHttpRouterFactoryOptions = {\n /**\n * The path to forward all unmatched requests to. Defaults to '/api/app'\n */\n indexPath?: string | false;\n\n configure?(options: RootHttpRouterConfigureOptions): void;\n};\n\nfunction defaultConfigure({\n app,\n routes,\n middleware,\n}: RootHttpRouterConfigureOptions) {\n app.use(middleware.helmet());\n app.use(middleware.cors());\n app.use(middleware.compression());\n app.use(middleware.logging());\n app.use(routes);\n app.use(middleware.notFound());\n app.use(middleware.error());\n}\n\n/** @public */\nexport const rootHttpRouterFactory = createServiceFactory({\n service: coreServices.rootHttpRouter,\n deps: {\n config: coreServices.config,\n rootLogger: coreServices.rootLogger,\n lifecycle: coreServices.rootLifecycle,\n },\n async factory(\n { config, rootLogger, lifecycle },\n {\n indexPath,\n configure = defaultConfigure,\n }: RootHttpRouterFactoryOptions = {},\n ) {\n const router = new RestrictedIndexedRouter(indexPath ?? '/api/app');\n const logger = rootLogger.child({ service: 'rootHttpRouter' });\n\n const app = express();\n\n const middleware = MiddlewareFactory.create({ config, logger });\n\n configure({\n app,\n routes: router.handler(),\n middleware,\n config,\n logger,\n lifecycle,\n });\n\n const server = await createHttpServer(\n app,\n readHttpServerOptions(config.getOptionalConfig('backend')),\n { logger },\n );\n\n lifecycle.addShutdownHook({\n async fn() {\n await server.stop();\n },\n logger,\n });\n\n await server.start();\n\n return router;\n },\n});\n","/*\n * Copyright 2022 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 { CacheManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const cacheFactory = createServiceFactory({\n service: coreServices.cache,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const cacheManager = CacheManager.fromConfig(config);\n return async ({ plugin }) => {\n return cacheManager.forPlugin(plugin.getId());\n };\n },\n});\n","/*\n * Copyright 2022 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 loadBackendConfig,\n loggerToWinstonLogger,\n} from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const configFactory = createServiceFactory({\n service: coreServices.config,\n deps: {\n logger: coreServices.rootLogger,\n },\n async factory({ logger }) {\n const config = await loadBackendConfig({\n argv: process.argv,\n logger: loggerToWinstonLogger(logger),\n });\n return config;\n },\n});\n","/*\n * Copyright 2022 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 { DatabaseManager } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const databaseFactory = createServiceFactory({\n service: coreServices.database,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const databaseManager = DatabaseManager.fromConfig(config);\n return async ({ plugin }) => {\n return databaseManager.forPlugin(plugin.getId());\n };\n },\n});\n","/*\n * Copyright 2022 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 { SingleHostDiscovery } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const discoveryFactory = createServiceFactory({\n service: coreServices.discovery,\n deps: {\n config: coreServices.config,\n },\n async factory({ config }) {\n const discovery = SingleHostDiscovery.fromConfig(config);\n return async () => {\n return discovery;\n };\n },\n});\n","/*\n * Copyright 2022 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 createServiceFactory,\n coreServices,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const loggerFactory = createServiceFactory({\n service: coreServices.logger,\n deps: {\n rootLogger: coreServices.rootLogger,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ rootLogger }) {\n return async ({ plugin }) => {\n return rootLogger.child({ plugin: plugin.getId() });\n };\n },\n});\n","/*\n * Copyright 2022 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 { createRootLogger } from '@backstage/backend-common';\nimport {\n createServiceFactory,\n LoggerService,\n coreServices,\n} from '@backstage/backend-plugin-api';\nimport { LogMeta } from '@backstage/backend-plugin-api';\nimport { Logger as WinstonLogger } from 'winston';\n\nclass BackstageLogger implements LoggerService {\n static fromWinston(logger: WinstonLogger): BackstageLogger {\n return new BackstageLogger(logger);\n }\n\n private constructor(private readonly winston: WinstonLogger) {}\n\n error(message: string, meta?: LogMeta): void {\n this.winston.error(message, meta);\n }\n\n warn(message: string, meta?: LogMeta): void {\n this.winston.warn(message, meta);\n }\n\n info(message: string, meta?: LogMeta): void {\n this.winston.info(message, meta);\n }\n\n debug(message: string, meta?: LogMeta): void {\n this.winston.debug(message, meta);\n }\n\n child(meta: LogMeta): LoggerService {\n return new BackstageLogger(this.winston.child(meta));\n }\n}\n\n/** @public */\nexport const rootLoggerFactory = createServiceFactory({\n service: coreServices.rootLogger,\n deps: {},\n async factory() {\n return BackstageLogger.fromWinston(createRootLogger());\n },\n});\n","/*\n * Copyright 2022 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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { ServerPermissionClient } from '@backstage/plugin-permission-node';\n\n/** @public */\nexport const permissionsFactory = createServiceFactory({\n service: coreServices.permissions,\n deps: {\n config: coreServices.config,\n discovery: coreServices.discovery,\n tokenManager: coreServices.tokenManager,\n },\n async factory({ config }) {\n return async ({ discovery, tokenManager }) => {\n return ServerPermissionClient.fromConfig(config, {\n discovery,\n tokenManager,\n });\n };\n },\n});\n","/*\n * Copyright 2022 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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport { TaskScheduler } from '@backstage/backend-tasks';\n\n/** @public */\nexport const schedulerFactory = createServiceFactory({\n service: coreServices.scheduler,\n deps: {\n config: coreServices.config,\n plugin: coreServices.pluginMetadata,\n },\n async factory({ config }) {\n const taskScheduler = TaskScheduler.fromConfig(config);\n return async ({ plugin }) => {\n return taskScheduler.forPlugin(plugin.getId());\n };\n },\n});\n","/*\n * Copyright 2022 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 coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\nimport {\n loggerToWinstonLogger,\n ServerTokenManager,\n} from '@backstage/backend-common';\n\n/** @public */\nexport const tokenManagerFactory = createServiceFactory({\n service: coreServices.tokenManager,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return ServerTokenManager.fromConfig(config, {\n logger: loggerToWinstonLogger(logger),\n });\n };\n },\n});\n","/*\n * Copyright 2022 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 { loggerToWinstonLogger, UrlReaders } from '@backstage/backend-common';\nimport {\n coreServices,\n createServiceFactory,\n} from '@backstage/backend-plugin-api';\n\n/** @public */\nexport const urlReaderFactory = createServiceFactory({\n service: coreServices.urlReader,\n deps: {\n config: coreServices.config,\n logger: coreServices.logger,\n },\n async factory() {\n return async ({ config, logger }) => {\n return UrlReaders.default({\n config,\n logger: loggerToWinstonLogger(logger),\n });\n };\n },\n});\n","/*\n * Copyright 2022 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 */\nimport {\n createServiceFactory,\n coreServices,\n LifecycleServiceShutdownHook,\n} from '@backstage/backend-plugin-api';\n\n/**\n * Allows plugins to register shutdown hooks that are run when the process is about to exit.\n * @public */\nexport const lifecycleFactory = createServiceFactory({\n service: coreServices.lifecycle,\n deps: {\n logger: coreServices.logger,\n rootLifecycle: coreServices.rootLifecycle,\n pluginMetadata: coreServices.pluginMetadata,\n },\n async factory({ rootLifecycle }) {\n return async ({ logger, pluginMetadata }) => {\n const plugin = pluginMetadata.getId();\n return {\n addShutdownHook(options: LifecycleServiceShutdownHook): void {\n rootLifecycle.addShutdownHook({\n ...options,\n\n logger: options.logger?.child({ plugin }) ?? logger,\n });\n },\n };\n };\n },\n});\n"],"names":["fs","resolvePath","dirname","forge","stoppableServer","https","http","helmet","Minimatch","__privateAdd","__privateSet","compression","__privateGet","morgan","cors","serializeError","NotModifiedError","InputError","AuthenticationError","NotAllowedError","NotFoundError","ConflictError","createServiceFactory","coreServices","__privateMethod","stringifyError","Router","express","CacheManager","loadBackendConfig","loggerToWinstonLogger","DatabaseManager","SingleHostDiscovery","createRootLogger","ServerPermissionClient","TaskScheduler","ServerTokenManager","UrlReaders"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAM,YAAe,GAAA,IAAA,CAAA;AACrB,MAAM,YAAe,GAAA,EAAA,CAAA;AAgBd,SAAS,sBAAsB,MAAoC,EAAA;AACxE,EAAO,OAAA;AAAA,IACL,MAAA,EAAQ,sBAAsB,MAAM,CAAA;AAAA,IACpC,KAAA,EAAO,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