Introduce backend-defaults package

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-08-10 14:29:16 +02:00
parent a6b2cf31ca
commit ff118129d8
24 changed files with 293 additions and 44 deletions
@@ -0,0 +1,57 @@
/*
* Copyright 2022 The Backstage Authors
*
* 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.
*/
import {
Backend,
cacheFactory,
configFactory,
createSpecializedBackend,
databaseFactory,
discoveryFactory,
httpRouterFactory,
loggerFactory,
permissionsFactory,
schedulerFactory,
tokenManagerFactory,
urlReaderFactory,
} from '@backstage/backend-app-api';
import { CreateBackendOptions } from './types';
export const defaultServiceFactories = [
cacheFactory,
configFactory,
databaseFactory,
discoveryFactory,
loggerFactory,
permissionsFactory,
schedulerFactory,
tokenManagerFactory,
urlReaderFactory,
httpRouterFactory,
];
/**
* @public
*/
export function createBackend(options?: CreateBackendOptions): Backend {
// TODO: merge with provided APIs
return createSpecializedBackend({
serviceFactories: [
...defaultServiceFactories,
...(options?.serviceFactories || []),
],
});
}
+18
View File
@@ -0,0 +1,18 @@
/*
* Copyright 2022 The Backstage Authors
*
* 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 type { CreateBackendOptions } from './types';
export { createBackend } from './CreateBackend';
+24
View File
@@ -0,0 +1,24 @@
/*
* Copyright 2022 The Backstage Authors
*
* 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.
*/
import { AnyServiceFactory } from '@backstage/backend-plugin-api';
/**
* @public
*/
export interface CreateBackendOptions {
serviceFactories?: AnyServiceFactory[];
}