@backstage/backend-defaults
Version:
Backend defaults used by Backstage backend apps
69 lines (62 loc) • 2.29 kB
TypeScript
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
import { AuthService, HttpAuthService, RootConfigService, HttpRouterServiceAuthPolicy, LifecycleService } from '@backstage/backend-plugin-api';
import * as express from 'express';
import express__default, { RequestHandler } from 'express';
/**
* HTTP route registration for plugins.
*
* See {@link @backstage/code-plugin-api#HttpRouterService}
* and {@link https://backstage.io/docs/backend-system/core-services/http-router | the service docs}
* for more information.
*
* @public
*/
declare const httpRouterServiceFactory: _backstage_backend_plugin_api.ServiceFactory<_backstage_backend_plugin_api.HttpRouterService, "plugin", "singleton">;
/**
* @public
*/
declare function createAuthIntegrationRouter(options: {
auth: AuthService;
}): express__default.Router;
/**
* @public
*/
declare function createCredentialsBarrier(options: {
httpAuth: HttpAuthService;
config: RootConfigService;
}): {
middleware: RequestHandler;
addAuthPolicy: (policy: HttpRouterServiceAuthPolicy) => void;
};
/**
* Options for {@link createLifecycleMiddleware}.
* @public
*/
interface LifecycleMiddlewareOptions {
config: RootConfigService;
lifecycle: LifecycleService;
}
/**
* Creates a middleware that pauses requests until the service has started.
*
* @remarks
*
* Requests that arrive before the service has started will be paused until startup is complete.
* If the service does not start within the provided timeout, the request will be rejected with a
* {@link @backstage/errors#ServiceUnavailableError}.
*
* If the service is shutting down, all requests will be rejected with a
* {@link @backstage/errors#ServiceUnavailableError}.
*
* @public
*/
declare function createLifecycleMiddleware(options: LifecycleMiddlewareOptions): RequestHandler;
/**
* @public
* Creates a middleware that can be used to refresh the cookie for the user.
*/
declare function createCookieAuthRefreshMiddleware(options: {
auth: AuthService;
httpAuth: HttpAuthService;
}): express.Router;
export { type LifecycleMiddlewareOptions, createAuthIntegrationRouter, createCookieAuthRefreshMiddleware, createCredentialsBarrier, createLifecycleMiddleware, httpRouterServiceFactory };