Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@backstage/backend-common
Advanced tools
@backstage/backend-common is a utility library for building backend services in the Backstage ecosystem. It provides common functionalities such as logging, database connections, and server setup, which are essential for developing robust and scalable backend services.
Logging
Provides a root logger that can be used throughout the application for consistent logging.
const { getRootLogger } = require('@backstage/backend-common');
const logger = getRootLogger();
logger.info('This is an info message');
Database Connection
Helps in setting up and managing database connections using a configuration object.
const { DatabaseManager } = require('@backstage/backend-common');
const config = { /* database configuration */ };
const databaseManager = DatabaseManager.fromConfig(config);
const db = databaseManager.forPlugin('my-plugin');
Server Setup
Simplifies the process of setting up a web server with routing and middleware.
const { createServiceBuilder } = require('@backstage/backend-common');
const service = createServiceBuilder(module)
.setPort(7000)
.addRouter('/api', myApiRouter)
.start();
Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. Unlike @backstage/backend-common, which is tailored for the Backstage ecosystem, Express is a general-purpose web framework.
Winston is a versatile logging library for Node.js. While @backstage/backend-common includes logging as one of its features, Winston is a dedicated logging library with more advanced features and customization options.
Knex is a SQL query builder for Node.js, designed to be flexible and portable. It provides a similar database management functionality as @backstage/backend-common but is more focused on query building and database migrations.
[!CAUTION] This package is deprecated and will be removed in a near future, so please follow the deprecated instructions for the exports you still use.
Common functionality library for Backstage backends, implementing logging, error handling and similar.
Add the library to your backend package:
# From your Backstage root directory
yarn --cwd packages/backend add @backstage/backend-common
then make use of the handlers and logger as necessary:
import {
errorHandler,
getRootLogger,
notFoundHandler,
requestLoggingHandler,
} from '@backstage/backend-common';
const app = express();
app.use(requestLoggingHandler());
app.use('/home', myHomeRouter);
app.use(notFoundHandler());
app.use(errorHandler());
app.listen(PORT, () => {
getRootLogger().info(`Listening on port ${PORT}`);
});
FAQs
Common functionality library for Backstage backends
The npm package @backstage/backend-common receives a total of 123,560 weekly downloads. As such, @backstage/backend-common popularity was classified as popular.
We found that @backstage/backend-common demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.