remove backend-common from notifications
Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-notifications-backend': patch
|
||||
---
|
||||
|
||||
Remove `@backstage/backend-common` dependency
|
||||
@@ -20,13 +20,13 @@ import {
|
||||
createBackendPlugin,
|
||||
} from '@backstage/backend-plugin-api';
|
||||
import { notificationService } from '@backstage/plugin-notifications-node';
|
||||
import { errorHandler } from '@backstage/backend-common';
|
||||
import {
|
||||
notificationSeverities,
|
||||
NotificationSeverity,
|
||||
} from '@backstage/plugin-notifications-common';
|
||||
import express, { Response } from 'express';
|
||||
import Router from 'express-promise-router';
|
||||
import { MiddlewareFactory } from '@backstage/backend-defaults/rootHttpRouter';
|
||||
|
||||
const randomSeverity = (): NotificationSeverity => {
|
||||
return notificationSeverities[
|
||||
@@ -77,8 +77,12 @@ const notificationsDebug = createBackendPlugin({
|
||||
deps: {
|
||||
notifications: notificationService,
|
||||
httpRouter: coreServices.httpRouter,
|
||||
config: coreServices.rootConfig,
|
||||
logger: coreServices.logger,
|
||||
},
|
||||
async init({ notifications, httpRouter }) {
|
||||
async init({ notifications, httpRouter, config, logger }) {
|
||||
const middleware = MiddlewareFactory.create({ config, logger });
|
||||
|
||||
const router = Router();
|
||||
router.use(express.json());
|
||||
router.post('/', async (_, res: Response<unknown>) => {
|
||||
@@ -96,7 +100,7 @@ const notificationsDebug = createBackendPlugin({
|
||||
});
|
||||
res.status(200).send({ status: 'ok' });
|
||||
});
|
||||
router.use(errorHandler());
|
||||
router.use(middleware.error());
|
||||
|
||||
httpRouter.use(router);
|
||||
httpRouter.addAuthPolicy({
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
"test": "backstage-cli package test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/backend-common": "^0.25.0",
|
||||
"@backstage/backend-plugin-api": "workspace:^",
|
||||
"@backstage/catalog-client": "workspace:^",
|
||||
"@backstage/catalog-model": "workspace:^",
|
||||
|
||||
@@ -14,16 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
DatabaseManager,
|
||||
PluginDatabaseManager,
|
||||
} from '@backstage/backend-common';
|
||||
import express from 'express';
|
||||
import request from 'supertest';
|
||||
import { createRouter } from './router';
|
||||
import { ConfigReader } from '@backstage/config';
|
||||
import { SignalsService } from '@backstage/plugin-signals-node';
|
||||
import {
|
||||
TestDatabases,
|
||||
mockCredentials,
|
||||
mockErrorHandler,
|
||||
mockServices,
|
||||
@@ -31,20 +27,9 @@ import {
|
||||
import { NotificationSendOptions } from '@backstage/plugin-notifications-node';
|
||||
import { catalogServiceMock } from '@backstage/plugin-catalog-node/testUtils';
|
||||
|
||||
function createDatabase(): PluginDatabaseManager {
|
||||
return DatabaseManager.fromConfig(
|
||||
new ConfigReader({
|
||||
backend: {
|
||||
database: {
|
||||
client: 'better-sqlite3',
|
||||
connection: ':memory:',
|
||||
},
|
||||
},
|
||||
}),
|
||||
).forPlugin('notifications');
|
||||
}
|
||||
|
||||
describe('createRouter', () => {
|
||||
const databases = TestDatabases.create();
|
||||
|
||||
let app: express.Express;
|
||||
|
||||
const signalService: jest.Mocked<SignalsService> = {
|
||||
@@ -62,9 +47,10 @@ describe('createRouter', () => {
|
||||
const catalog = catalogServiceMock();
|
||||
|
||||
beforeAll(async () => {
|
||||
const knex = await databases.init('SQLITE_3');
|
||||
const router = await createRouter({
|
||||
logger: mockServices.logger.mock(),
|
||||
database: createDatabase(),
|
||||
database: { getClient: async () => knex },
|
||||
signals: signalService,
|
||||
userInfo,
|
||||
config,
|
||||
|
||||
@@ -6716,7 +6716,6 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@backstage/plugin-notifications-backend@workspace:plugins/notifications-backend"
|
||||
dependencies:
|
||||
"@backstage/backend-common": ^0.25.0
|
||||
"@backstage/backend-defaults": "workspace:^"
|
||||
"@backstage/backend-plugin-api": "workspace:^"
|
||||
"@backstage/backend-test-utils": "workspace:^"
|
||||
|
||||
Reference in New Issue
Block a user