Implement location management
This commit is contained in:
@@ -39,13 +39,14 @@ import { PluginEnvironment } from './types';
|
||||
|
||||
const DEFAULT_PORT = 7000;
|
||||
const PORT = parseInt(process.env.PORT ?? '', 10) || DEFAULT_PORT;
|
||||
const pluginEnvironment: PluginEnvironment = {
|
||||
logger: getRootLogger().child({ type: 'plugin' }),
|
||||
};
|
||||
|
||||
async function main() {
|
||||
const database = await buildDatabase(getRootLogger());
|
||||
console.log(await database.select().from('locations'));
|
||||
|
||||
const pluginEnvironment: PluginEnvironment = {
|
||||
logger: getRootLogger().child({ type: 'plugin' }),
|
||||
database,
|
||||
};
|
||||
|
||||
const app = express();
|
||||
|
||||
|
||||
@@ -15,22 +15,12 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
AggregatorInventory,
|
||||
DatabaseInventory,
|
||||
createRouter,
|
||||
StaticInventory,
|
||||
} from '@backstage/plugin-inventory-backend';
|
||||
import type { PluginEnvironment } from '../types';
|
||||
|
||||
export default async function ({ logger }: PluginEnvironment) {
|
||||
const inventory = new AggregatorInventory();
|
||||
inventory.enlist(
|
||||
new StaticInventory([
|
||||
{ id: 'component1' },
|
||||
{ id: 'component2' },
|
||||
{ id: 'component3' },
|
||||
{ id: 'component4' },
|
||||
]),
|
||||
);
|
||||
import { PluginEnvironment } from '../types';
|
||||
|
||||
export default async function({ logger, database }: PluginEnvironment) {
|
||||
const inventory = new DatabaseInventory(database);
|
||||
return await createRouter({ inventory, logger });
|
||||
}
|
||||
|
||||
@@ -14,8 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import type { Logger } from 'winston';
|
||||
import Knex from 'knex';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
export type PluginEnvironment = {
|
||||
logger: Logger;
|
||||
database: Knex;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user