Backstage Backend’s Heart: A Complete Dissection of @backstage/backend-common! πŸ› οΈ

Hello, platform engineers! When customizing Backstage or creating new backend plugins, there’s one library you’re bound to encounter: @backstage/backend-common. Knowing the powerful tools this library provides can cut your development time in half. ⏱️


1. What is @backstage/backend-common? πŸ”

This package is like a “treasure trove of common utilities” in the Backstage backend ecosystem. It provides repeatedly needed functionalities for building backend services in a standardized way, helping developers focus solely on business logic.


2. Key Features Provided (Core Utilities) πŸ› οΈ

The main utilities provided by this library are as follows:

  • Database Helpers: Provides tools based on Knex.js to easily manage database configurations and execute migrations. πŸ—„οΈ
  • Logging: Offers a standardized logging interface based on the Winston library, allowing all plugins to log in the same format. πŸ“
  • Error Handling: Provides standard HTTP error classes like NotFoundError and ConflictError to ensure consistent API responses. ⚠️
  • Token Management: Includes helpers for generating and validating tokens required for inter-service communication. πŸ”‘

3. Integration Helpers 🀝

Backstage’s biggest advantage is its extensibility. This library includes powerful features for integrating with external systems.

  • UrlReader: Provides a unified interface to read files from various source code hosting services such as GitHub, GitLab, and Bitbucket. 🌐
  • Config Loading: Responsible for safely reading and validating configurations from the app-config.yaml file.
  • Discovery: Supports a discovery mechanism that dynamically finds the location (URL) of other backend services.

4. Why should you use this library? πŸ’‘

It’s not just about convenience. The reason to use @backstage/backend-common is Consistency.

  1. Standard Compliance: You can follow the best practices defined by the Backstage core team.
  2. Ease of Maintenance: If all plugins use the same common utilities, system updates or refactoring become much smoother.
  3. Proven Stability: You can use stable code that is already being used by numerous companies. βœ…

5. Latest Trend: New Backend System πŸ†•

Recently, Backstage has been evolving into the “New Backend System.” As a result, functionalities that were in @backstage/backend-common are tending to move to more specialized packages (e.g., @backstage/backend-plugin-api, @backstage/backend-defaults). However, this library still plays a pivotal role in existing plugins and legacy code.


6. Conclusion 🏁

It’s no exaggeration to say that Backstage backend development largely depends on how well you utilize this common library. If you’re planning to create a new plugin, first check if the functionalities you need are already implemented within this package!


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *