backstage-grpc-playground-backend
v0.3.2
Published
A backend plugin for Backstage supporting gRPC playground
Downloads
1,126
Maintainers
Readme
backstage-grpc-playground-backend
Overview
This repo contains backend code of the backstage-grpc-playground
Install
Install backstage-grpc-playground-backend for packages/backend
E.g: In your backstage project root
yarn --cwd packages/backend add backstage-grpc-playground-backend
Usage
Register the plugin in 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,
});
}
Register /grpc-playground
path in backstage backend
// 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());
}
Examples
See examples
Acknowledgements
- Thanks to Backstage Team for creating an incredable framework
- Thanks to the authors of the awesome BloomRPC Application
- Feel free to submit new issues