Files
backstage/packages/backend-common/README.md
T
Fredrik Adelöw 92feb76252 Make the inventory backend standalone runnable
And also make a proposed split of how the loggers are handled.

Now logs look like

```
{
  "type": "incomingRequest",
  "service": "backstage",
  "timestamp": "2020-04-30T14:29:04.002Z",
  "message": "...",
  "level": "info"
}
```

for requests, and then if the plugin logs something properly

```
{
  "type": "plugin",
  "service": "backstage",
  "plugin": "inventory",
  "timestamp": "2020-04-30T14:29:04.002Z",
  "message": "...",
  "level": "info"
}
```
2020-05-01 21:59:20 +02:00

846 B

@backstage/backend-common

Common functionality library for Backstage backends, implementing logging, error handling and similar.

Usage

Add the library to your backend package:

yarn 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}`);
});

Documentation