This repo contains backend code of the backstage-grpc-playground
Install backstage-grpc-playground-backend for packages/backend
E.g: In your backstage project root
yarn --cwd packages/backend add backstage-grpc-playground-backend
Create a new file packages/backend/src/plugins/grpc-playground.ts
// packages/backend/src/plugins/grpc-playground.ts
import { ScmIntegrations } from '@backstage/integration';
import { createRouter } from 'backstage-grpc-playground-backend';
import { Router } from 'express';
import { PluginEnvironment } from '../types';
export default async function createPlugin(
env: PluginEnvironment,
): Promise<Router> {
const { config, reader } = env;
const integrations = ScmIntegrations.fromConfig(config);
return await createRouter({
logger: env.logger,
reader,
integrations,
database: env.database,
});
}
// packages/backend/src/index.ts
import grpcPlayground from './plugins/grpc-playground';
async function main() {
// other env
const grpcPlaygroundEnv = useHotMemoize(module, () => createEnv('grpc-playground'));
// init router
// ...
// register before notFoundHandler
apiRouter.use('/grpc-playground', await grpcPlayground(grpcPlaygroundEnv));
// not found handler
apiRouter.use(notFoundHandler());
}
See examples
- Thanks to Backstage Team for creating an incredable framework
- Thanks to the authors of the awesome BloomRPC Application
- Feel free to submit new issues