@@ -2,4 +2,4 @@
|
||||
'@backstage/backend-app-api': patch
|
||||
---
|
||||
|
||||
Moved the options of the config service out to the factory itself, where it belongs
|
||||
Moved the options of the `config` and `rootHttpRouter` services out to the factories themselves, where they belong
|
||||
|
||||
@@ -232,7 +232,9 @@ export interface RootHttpRouterConfigureOptions {
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
export const rootHttpRouterFactory: () => ServiceFactory<RootHttpRouterService>;
|
||||
export const rootHttpRouterFactory: (
|
||||
options?: RootHttpRouterFactoryOptions | undefined,
|
||||
) => ServiceFactory<RootHttpRouterService>;
|
||||
|
||||
// @public (undocumented)
|
||||
export type RootHttpRouterFactoryOptions = {
|
||||
|
||||
+33
-36
@@ -69,45 +69,42 @@ function defaultConfigure({
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export const rootHttpRouterFactory = createServiceFactory({
|
||||
service: coreServices.rootHttpRouter,
|
||||
deps: {
|
||||
config: coreServices.config,
|
||||
rootLogger: coreServices.rootLogger,
|
||||
lifecycle: coreServices.rootLifecycle,
|
||||
},
|
||||
async factory(
|
||||
{ config, rootLogger, lifecycle },
|
||||
{
|
||||
indexPath,
|
||||
configure = defaultConfigure,
|
||||
}: RootHttpRouterFactoryOptions = {},
|
||||
) {
|
||||
const logger = rootLogger.child({ service: 'rootHttpRouter' });
|
||||
const app = express();
|
||||
export const rootHttpRouterFactory = createServiceFactory(
|
||||
(options?: RootHttpRouterFactoryOptions) => ({
|
||||
service: coreServices.rootHttpRouter,
|
||||
deps: {
|
||||
config: coreServices.config,
|
||||
rootLogger: coreServices.rootLogger,
|
||||
lifecycle: coreServices.rootLifecycle,
|
||||
},
|
||||
async factory({ config, rootLogger, lifecycle }) {
|
||||
const { indexPath, configure = defaultConfigure } = options ?? {};
|
||||
const logger = rootLogger.child({ service: 'rootHttpRouter' });
|
||||
const app = express();
|
||||
|
||||
const router = DefaultRootHttpRouter.create({ indexPath });
|
||||
const middleware = MiddlewareFactory.create({ config, logger });
|
||||
const router = DefaultRootHttpRouter.create({ indexPath });
|
||||
const middleware = MiddlewareFactory.create({ config, logger });
|
||||
|
||||
configure({
|
||||
app,
|
||||
routes: router.handler(),
|
||||
middleware,
|
||||
config,
|
||||
logger,
|
||||
lifecycle,
|
||||
});
|
||||
configure({
|
||||
app,
|
||||
routes: router.handler(),
|
||||
middleware,
|
||||
config,
|
||||
logger,
|
||||
lifecycle,
|
||||
});
|
||||
|
||||
const server = await createHttpServer(
|
||||
app,
|
||||
readHttpServerOptions(config.getOptionalConfig('backend')),
|
||||
{ logger },
|
||||
);
|
||||
const server = await createHttpServer(
|
||||
app,
|
||||
readHttpServerOptions(config.getOptionalConfig('backend')),
|
||||
{ logger },
|
||||
);
|
||||
|
||||
lifecycle.addShutdownHook(() => server.stop());
|
||||
lifecycle.addShutdownHook(() => server.stop());
|
||||
|
||||
await server.start();
|
||||
await server.start();
|
||||
|
||||
return router;
|
||||
},
|
||||
});
|
||||
return router;
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user