diff --git a/CHANGELOG.md b/CHANGELOG.md index c5229a6794..487b94a39d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,13 +8,16 @@ If you encounter issues while upgrading to a newer version, don't hesitate to re > Collect changes for the next release below +### Backend (example-backend, or backends created with @backstage/create-app) + +- A plugin database manager has been created, and plugins can now accept that interface as an argument during initialisation. Notably, the `auth` plugin has a [`createRouter` signature change](./plugins/auth-backend/src/service/router.ts). See [packages/backend/src/index.ts](./packages/backend/src/index.ts) on how to set it up. [#2697](https://github.com/spotify/backstage/pull/2697) + ## v0.1.1-alpha.24 ### Backend (example-backend, or backends created with @backstage/create-app) - The default mount point for backend plugins have been changed to `/api`. These changes are done in the backend package itself, so it is recommended that you sync up existing backend packages with this new pattern. [#2562](https://github.com/spotify/backstage/pull/2562) - A service discovery mechanism for backend plugins has been added, and is now a requirement for several backend plugins. See [packages/backend/src/index.ts](./packages/backend/src/index.ts) for how to set it up using `SingleHostDiscovery` from `@backstage/backend-common`. Note that the default base path for plugins is set to `/api` to that change, but it can be set to use the old behavior via the `basePath` option. [#2600](https://github.com/spotify/backstage/pull/2600) -- A plugin database manager has been created, and plugins can now accept that interface as an argument during initialisation. Notably, the `auth` plugin has a [`createRouter` signature change](./plugins/auth-backend/src/service/router.ts). See [packages/backend/src/index.ts](./packages/backend/src/index.ts) on how to set it up. [#2697](https://github.com/spotify/backstage/pull/2697) ### @backstage/auth-backend diff --git a/packages/backend-common/src/database/SingleConnection.ts b/packages/backend-common/src/database/SingleConnection.ts index f8c86838a1..777ced54a0 100644 --- a/packages/backend-common/src/database/SingleConnection.ts +++ b/packages/backend-common/src/database/SingleConnection.ts @@ -22,11 +22,10 @@ import { PluginDatabaseManager } from './types'; /** * Implements a Database Manager which will automatically create new databases * for plugins when requested. All requested databases are created with the - * credentials provided. + * credentials provided; if the database already exists no attempt to create + * the database will be made. */ export class SingleConnectionDatabaseManager { - private readonly config: Config; - /** * Creates a new SingleConnectionDatabaseManager instance by reading from the `backend` * config section, specifically the `.database` key for discovering the management @@ -40,17 +39,7 @@ export class SingleConnectionDatabaseManager { ); } - private constructor(config: Config) { - this.config = config; - } - - private getDatabaseConfig(): Config { - return this.config; - } - - private getAdminConfig(): Config { - return this.config; - } + private constructor(private readonly config: Config) {} /** * Generates a PluginDatabaseManager for consumption by plugins. @@ -68,7 +57,7 @@ export class SingleConnectionDatabaseManager { } private async getDatabase(pluginId: string): Promise { - const config = this.getDatabaseConfig(); + const config = this.config; const overrides = SingleConnectionDatabaseManager.getDatabaseOverrides( pluginId, ); @@ -87,7 +76,7 @@ export class SingleConnectionDatabaseManager { } private async ensureDatabase(database: string) { - const config = this.getAdminConfig(); + const config = this.config; await ensureDatabaseExists(config, database); } }