@backstage/backend-app-api
Version:
Core API used by Backstage backend apps
123 lines (118 loc) • 2.8 kB
TypeScript
import { BackendFeature, ServiceFactory } from '@backstage/backend-plugin-api';
import { CustomErrorBase } from '@backstage/errors';
/**
* @public
*/
interface Backend {
add(feature: BackendFeature | Promise<{
default: BackendFeature;
}>): void;
start(): Promise<{
result: BackendStartupResult;
}>;
stop(): Promise<void>;
}
/**
* @public
*/
interface CreateSpecializedBackendOptions {
defaultServiceFactories: ServiceFactory[];
}
/**
* Result of a module startup attempt.
* @public
*/
interface ModuleStartupResult {
/**
* The time the module startup was completed.
*/
resultAt: Date;
/**
* The ID of the module.
*/
moduleId: string;
/**
* If the startup failed, this contains information about the failure.
*/
failure?: {
/**
* The error that occurred during startup, if any.
*/
error: Error;
/**
* Whether the failure was allowed.
*/
allowed: boolean;
};
}
/**
* Result of a plugin startup attempt.
* @public
*/
interface PluginStartupResult {
/**
* The time the plugin startup was completed.
*/
resultAt: Date;
/**
* If the startup failed, this contains information about the failure.
*/
failure?: {
/**
* The error that occurred during startup, if any.
*/
error: Error;
/**
* Whether the failure was allowed.
*/
allowed: boolean;
};
/**
* The ID of the plugin.
*/
pluginId: string;
/**
* Results for all modules belonging to this plugin.
*/
modules: ModuleStartupResult[];
}
/**
* Result of a backend startup attempt.
* @public
*/
interface BackendStartupResult {
/**
* The time the backend startup started.
*/
beginAt: Date;
/**
* The time the backend startup was completed.
*/
resultAt: Date;
/**
* Results for all plugins that were attempted to start.
*/
plugins: PluginStartupResult[];
/**
* The outcome of the backend startup.
*/
outcome: 'success' | 'failure';
}
/**
* @public
*/
declare function createSpecializedBackend(options: CreateSpecializedBackendOptions): Backend;
/**
* Error thrown when backend startup fails.
* Includes detailed startup results for all plugins and modules.
*
* @public
*/
declare class BackendStartupError extends CustomErrorBase {
#private;
name: "BackendStartupError";
constructor(startupResult: BackendStartupResult);
get result(): BackendStartupResult;
}
export { BackendStartupError, createSpecializedBackend };
export type { Backend, BackendStartupResult, CreateSpecializedBackendOptions, ModuleStartupResult, PluginStartupResult };