backend-next: widen accepted ServiceFactory types to include meta method
Co-authored-by: Fredrik Adelöw <freben@gmail.com> Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -47,24 +47,14 @@ export const defaultServiceFactories = [
|
||||
* @public
|
||||
*/
|
||||
export interface CreateBackendOptions {
|
||||
services?: ServiceFactory[];
|
||||
services?: (ServiceFactory | (() => ServiceFactory))[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export function createBackend(options?: CreateBackendOptions): Backend {
|
||||
const services = new Map<string, ServiceFactory>(
|
||||
defaultServiceFactories.map(sf => [sf.service.id, sf as ServiceFactory]),
|
||||
);
|
||||
|
||||
if (options?.services) {
|
||||
for (const sf of options.services) {
|
||||
services.set(sf.service.id, sf);
|
||||
}
|
||||
}
|
||||
|
||||
return createSpecializedBackend({
|
||||
services: Array.from(services.values()),
|
||||
services: [...defaultServiceFactories, ...(options?.services ?? [])],
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user