or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

auth-permissions.mdcore-backend.mddatabase-storage.mdhttp-services.mdindex.mdservice-factories.mdutilities.md
tile.json

index.mddocs/

Backstage Backend Defaults

Backstage Backend Defaults is a comprehensive TypeScript library that provides default implementations and service factories for Backstage backend applications. It serves as a batteries-included foundation for building backend services with standardized authentication, database connectivity, HTTP routing, logging, caching, discovery, scheduling, and more.

Package Information

  • Package Name: @backstage/backend-defaults
  • Package Type: npm
  • Language: TypeScript
  • Installation: yarn add @backstage/backend-defaults

Core Imports

import { createBackend } from "@backstage/backend-defaults";

For specific service factories:

import { authServiceFactory } from "@backstage/backend-defaults/auth";
import { databaseServiceFactory } from "@backstage/backend-defaults/database";
import { loggerServiceFactory } from "@backstage/backend-defaults/logger";

Basic Usage

import { createBackend } from "@backstage/backend-defaults";

// Create a backend with all default service factories pre-configured
const backend = createBackend();

// Add your plugins
backend.add(import('@backstage/plugin-catalog-backend'));
backend.add(import('@backstage/plugin-scaffolder-backend'));

// Start the backend
await backend.start();

Architecture

Backstage Backend Defaults is built around several key architectural components:

  • Service Factories: Factory functions that create service instances for dependency injection
  • Modular Entry Points: 22 separate entry points allowing selective imports of specific services
  • Default Implementations: Ready-to-use implementations of all core backend services
  • Configuration-Driven: All services can be configured through Backstage's configuration system
  • Cloud Provider Support: Built-in support for AWS, Azure, and Google Cloud integrations

Capabilities

Core Backend Creation

The main API for creating a complete Backstage backend instance with all default services pre-configured.

/**
 * Creates a Backend instance with all default service factories pre-configured
 * @returns Backend instance ready for plugin installation
 */
function createBackend(): Backend;

/**
 * Discovers backend features from package.json and dependencies
 */
const discoveryFeatureLoader: FeatureLoader;

Core Backend

Service Factories

Comprehensive collection of service factories for all core backend services including authentication, database, logging, and more.

// Authentication services
const authServiceFactory: ServiceFactory;
const httpAuthServiceFactory: ServiceFactory;

// Database services  
const databaseServiceFactory: ServiceFactory;

// Logging and monitoring
const loggerServiceFactory: ServiceFactory;
const rootLoggerServiceFactory: ServiceFactory;
const auditorServiceFactory: ServiceFactory;

// HTTP and routing
const httpRouterServiceFactory: ServiceFactory;
const rootHttpRouterServiceFactory: ServiceFactory;

Service Factories

HTTP Services

HTTP server creation, routing, middleware, and authentication utilities for building REST APIs and web interfaces.

/**
 * Creates an HTTP server instance
 */
function createHttpServer(options: HttpServerOptions): ExtendedHttpServer;

/**
 * Creates router for authentication integrations
 */
function createAuthIntegrationRouter(): Router;

/**
 * Creates middleware for credentials validation
 */
function createCredentialsBarrier(): RequestHandler;

interface HttpServerOptions {
  listen?: { port?: number; host?: string };
  https?: HttpServerCertificateOptions | boolean;
}

HTTP Services

Database and Storage Services

Database connection management, migrations, and URL readers for various storage providers and source control systems.

class DatabaseManager {
  forPlugin(pluginId: string): Promise<Knex>;
}

interface DatabaseManagerOptions {
  migrations?: { skip?: boolean };
}

// URL readers for different providers
class GithubUrlReader implements UrlReader;
class GitlabUrlReader implements UrlReader;
class AwsS3UrlReader implements UrlReader;
class AzureBlobStorageUrlReader implements UrlReader;

Database and Storage

Authentication and Authorization

Authentication services, permissions, and user information management for secure backend operations.

class DefaultHttpAuthService implements HttpAuthService;

interface DefaultHttpAuthServiceOptions {
  defaultCredentials?: BackstageCredentials;
}

interface PluginTokenHandler {
  verifyToken(token: string): Promise<BackstageCredentials>;
}

const permissionsServiceFactory: ServiceFactory;
const userInfoServiceFactory: ServiceFactory;

Authentication and Authorization

Utilities and Infrastructure

Caching, scheduling, discovery, logging implementations, and configuration utilities.

class CacheManager {
  getClient(options?: CacheManagerOptions): Promise<CacheClient>;
}

class DefaultSchedulerService implements SchedulerService;

class HostDiscovery implements DiscoveryService {
  constructor(options: HostDiscoveryOptions);
}

interface HostDiscoveryOptions {
  basePath?: string;
  endpoints?: HostDiscoveryEndpoint[];
}

Utilities and Infrastructure