removed unnecessary database setup
Signed-off-by: Lykke Axlin <lykkeaxlin@hotmail.com> Co-authored-by: klaraab <klarabroman@live.se>
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
"@backstage/backend-common": "^0.9.2",
|
||||
"@backstage/config": "^0.1.5",
|
||||
"@types/express": "^4.17.6",
|
||||
"cross-fetch": "^3.0.6",
|
||||
"express": "^4.17.1",
|
||||
"express-promise-router": "^4.1.0",
|
||||
"knex": "^0.95.10",
|
||||
@@ -30,10 +29,7 @@
|
||||
"yn": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.7.6",
|
||||
"@types/supertest": "^2.0.8",
|
||||
"msw": "^0.29.0",
|
||||
"supertest": "^4.0.2"
|
||||
"@backstage/cli": "^0.7.6"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
|
||||
@@ -18,12 +18,10 @@ import {
|
||||
errorHandler,
|
||||
PluginDatabaseManager,
|
||||
resolvePackagePath,
|
||||
useHotMemoize,
|
||||
} from '@backstage/backend-common';
|
||||
import express from 'express';
|
||||
import Router from 'express-promise-router';
|
||||
import { Logger } from 'winston';
|
||||
import Knex from 'knex';
|
||||
import { Config } from '@backstage/config';
|
||||
|
||||
export interface RouterOptions {
|
||||
@@ -35,39 +33,17 @@ export interface RouterOptions {
|
||||
export async function createRouter(
|
||||
options: RouterOptions,
|
||||
): Promise<express.Router> {
|
||||
const { logger, config } = options;
|
||||
const { logger } = options;
|
||||
const db = await options.database?.getClient();
|
||||
|
||||
const connection = config
|
||||
.getConfig('backend')
|
||||
.getConfig('database')
|
||||
.getConfig('connection');
|
||||
|
||||
logger.info('Initializing Bazaar backend');
|
||||
|
||||
const database = useHotMemoize(module, () => {
|
||||
const knex = Knex({
|
||||
client: 'postgresql',
|
||||
connection: {
|
||||
database: 'backstage_plugin_bazaar',
|
||||
user: connection.getString('user'),
|
||||
password: connection.getString('password'),
|
||||
},
|
||||
useNullAsDefault: true,
|
||||
});
|
||||
|
||||
knex.client.pool.on('createSuccess', (_eventId: any, resource: any) => {
|
||||
resource.run('PRAGMA foreign_keys = ON', () => {});
|
||||
});
|
||||
return knex;
|
||||
});
|
||||
|
||||
const migrationsDir = resolvePackagePath(
|
||||
'@backstage/plugin-bazaar-backend',
|
||||
'migrations',
|
||||
);
|
||||
|
||||
await database?.migrate.latest({
|
||||
await db?.migrate.latest({
|
||||
directory: migrationsDir,
|
||||
});
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
"dependencies": {
|
||||
"@backstage/catalog-model": "^0.9.0",
|
||||
"@backstage/cli": "^0.7.2",
|
||||
"@backstage/core-api": "^0.2.23",
|
||||
"@backstage/core-components": "^0.4.1",
|
||||
"@backstage/core-plugin-api": "^0.1.3",
|
||||
"@backstage/plugin-catalog": "^0.6.6",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import { Entity } from '@backstage/catalog-model';
|
||||
import { IdentityApi } from '@backstage/core-api';
|
||||
import { IdentityApi } from '@backstage/core-plugin-api';
|
||||
import { BazaarProject, Status } from './types';
|
||||
|
||||
export const getEntityRef = (entity: Entity) => {
|
||||
|
||||
Reference in New Issue
Block a user