Merge branch 'master' into rugvip/mod
This commit is contained in:
@@ -6,9 +6,7 @@ The main purpose of this package is to provide a test bed for Backstage plugins
|
||||
that have a backend part. Feel free to experiment locally or within your fork
|
||||
by adding dependencies and routes to this backend, to try things out.
|
||||
|
||||
Our goal is to eventually amend the create-app flow of the CLI, such that a
|
||||
production ready version of a backend skeleton is made alongside the frontend
|
||||
app. Until then, feel free to experiment here!
|
||||
By running the `@backstage/create-app` script, you get your own separate Backstage backend.
|
||||
|
||||
## Development
|
||||
|
||||
|
||||
@@ -71,9 +71,16 @@ function makeCreateEnv(config: Config) {
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const logger = getRootLogger();
|
||||
|
||||
logger.info(
|
||||
`You are running an example backend, which is supposed to be mainly used for contributing back to Backstage. ` +
|
||||
`Do NOT deploy this to production. Read more here https://backstage.io/docs/getting-started/`,
|
||||
);
|
||||
|
||||
const config = await loadBackendConfig({
|
||||
argv: process.argv,
|
||||
logger: getRootLogger(),
|
||||
logger,
|
||||
});
|
||||
const createEnv = makeCreateEnv(config);
|
||||
|
||||
@@ -118,7 +125,7 @@ async function main() {
|
||||
.addRouter('', await app(appEnv));
|
||||
|
||||
await service.start().catch(err => {
|
||||
console.log(err);
|
||||
logger.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
"@types/webpack": "^4.41.7",
|
||||
"@types/webpack-dev-server": "^3.11.0",
|
||||
"@types/yarnpkg__lockfile": "^1.1.4",
|
||||
"del": "^5.1.0",
|
||||
"del": "^6.0.0",
|
||||
"mock-fs": "^4.13.0",
|
||||
"nodemon": "^2.0.2",
|
||||
"ts-node": "^9.1.1"
|
||||
|
||||
@@ -394,6 +394,11 @@ export type SignInResult = {
|
||||
signOut?: () => Promise<void>;
|
||||
};
|
||||
|
||||
// @public (undocumented)
|
||||
export class UnhandledErrorForwarder {
|
||||
static forward(errorApi: ErrorApi, errorContext: ErrorContext): void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export class UrlPatternDiscovery implements DiscoveryApi {
|
||||
static compile(pattern: string): UrlPatternDiscovery;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import { ErrorApi, ErrorContext } from '@backstage/core-plugin-api';
|
||||
|
||||
/*
|
||||
* Copyright 2020 Spotify AB
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export class UnhandledErrorForwarder {
|
||||
/**
|
||||
* Add event listener, such that unhandled errors can be forwarded using an given `ErrorApi` instance
|
||||
*/
|
||||
static forward(errorApi: ErrorApi, errorContext: ErrorContext) {
|
||||
window.addEventListener(
|
||||
'unhandledrejection',
|
||||
(e: PromiseRejectionEvent) => {
|
||||
errorApi.post(e.reason as Error, errorContext);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -16,3 +16,4 @@
|
||||
|
||||
export { ErrorAlerter } from './ErrorAlerter';
|
||||
export { ErrorApiForwarder } from './ErrorApiForwarder';
|
||||
export { UnhandledErrorForwarder } from './UnhandledErrorForwarder';
|
||||
|
||||
@@ -30,6 +30,7 @@ import {
|
||||
UrlPatternDiscovery,
|
||||
SamlAuth,
|
||||
OneLoginAuth,
|
||||
UnhandledErrorForwarder,
|
||||
} from '../apis';
|
||||
|
||||
import {
|
||||
@@ -67,8 +68,11 @@ export const defaultApis = [
|
||||
createApiFactory({
|
||||
api: errorApiRef,
|
||||
deps: { alertApi: alertApiRef },
|
||||
factory: ({ alertApi }) =>
|
||||
new ErrorAlerter(alertApi, new ErrorApiForwarder()),
|
||||
factory: ({ alertApi }) => {
|
||||
const errorApi = new ErrorAlerter(alertApi, new ErrorApiForwarder());
|
||||
UnhandledErrorForwarder.forward(errorApi, { hidden: false });
|
||||
return errorApi;
|
||||
},
|
||||
}),
|
||||
createApiFactory({
|
||||
api: storageApiRef,
|
||||
|
||||
@@ -37,6 +37,7 @@ describe('index', () => {
|
||||
ConfigReader: expect.any(Function),
|
||||
ErrorAlerter: expect.any(Function),
|
||||
ErrorApiForwarder: expect.any(Function),
|
||||
UnhandledErrorForwarder: expect.any(Function),
|
||||
FeatureFlagged: expect.any(Function),
|
||||
GithubAuth: expect.any(Function),
|
||||
GitlabAuth: expect.any(Function),
|
||||
|
||||
Reference in New Issue
Block a user