-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(awards): support new backend system (#61)
BREAKING CHANGE: The awards-backend plugin will no longer be able to run on the old plugin system. See the [migration guide](https://backstage.io/docs/backend-system/building-backends/migrating/) for more info.
- Loading branch information
Showing
25 changed files
with
393 additions
and
709 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,7 @@ techdocs: | |
auth: | ||
environment: development | ||
providers: | ||
'dummy-auth': {} | ||
guest: {} | ||
|
||
catalog: | ||
rules: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,114 +1,40 @@ | ||
/* | ||
* Hi! | ||
* | ||
* Note that this is an EXAMPLE Backstage backend. Please check the README. | ||
* | ||
* Happy hacking! | ||
*/ | ||
|
||
import { | ||
CacheManager, | ||
DatabaseManager, | ||
HostDiscovery, | ||
ServerTokenManager, | ||
createServiceBuilder, | ||
getRootLogger, | ||
loadBackendConfig, | ||
notFoundHandler, | ||
useHotMemoize, | ||
} from '@backstage/backend-common'; | ||
import { TaskScheduler } from '@backstage/backend-tasks'; | ||
import { Config } from '@backstage/config'; | ||
import { DefaultIdentityClient } from '@backstage/plugin-auth-node'; | ||
import { ServerPermissionClient } from '@backstage/plugin-permission-node'; | ||
import Router from 'express-promise-router'; | ||
import app from './plugins/app'; | ||
import auth from './plugins/auth'; | ||
import awards from './plugins/awards'; | ||
import catalog from './plugins/catalog'; | ||
import proxy from './plugins/proxy'; | ||
import scaffolder from './plugins/scaffolder'; | ||
import search from './plugins/search'; | ||
import techdocs from './plugins/techdocs'; | ||
import { PluginEnvironment } from './types'; | ||
|
||
function makeCreateEnv(config: Config) { | ||
const root = getRootLogger(); | ||
const discovery = HostDiscovery.fromConfig(config); | ||
const cacheManager = CacheManager.fromConfig(config); | ||
const databaseManager = DatabaseManager.fromConfig(config, { logger: root }); | ||
const tokenManager = ServerTokenManager.noop(); | ||
const taskScheduler = TaskScheduler.fromConfig(config, { databaseManager }); | ||
|
||
const identity = DefaultIdentityClient.create({ | ||
discovery, | ||
}); | ||
const permissions = ServerPermissionClient.fromConfig(config, { | ||
discovery, | ||
tokenManager, | ||
}); | ||
|
||
return (plugin: string): PluginEnvironment => { | ||
const logger = root.child({ type: 'plugin', plugin }); | ||
const database = databaseManager.forPlugin(plugin); | ||
const cache = cacheManager.forPlugin(plugin); | ||
const scheduler = taskScheduler.forPlugin(plugin); | ||
return { | ||
logger, | ||
database, | ||
cache, | ||
config, | ||
discovery, | ||
tokenManager, | ||
scheduler, | ||
reader: undefined as any, | ||
permissions, | ||
identity, | ||
}; | ||
}; | ||
} | ||
|
||
async function main() { | ||
const config = await loadBackendConfig({ | ||
argv: process.argv, | ||
logger: getRootLogger(), | ||
}); | ||
const createEnv = makeCreateEnv(config); | ||
|
||
const catalogEnv = useHotMemoize(module, () => createEnv('catalog')); | ||
const scaffolderEnv = useHotMemoize(module, () => createEnv('scaffolder')); | ||
const authEnv = useHotMemoize(module, () => createEnv('auth')); | ||
const proxyEnv = useHotMemoize(module, () => createEnv('proxy')); | ||
const techdocsEnv = useHotMemoize(module, () => createEnv('techdocs')); | ||
const searchEnv = useHotMemoize(module, () => createEnv('search')); | ||
const appEnv = useHotMemoize(module, () => createEnv('app')); | ||
const awardsEnv = useHotMemoize(module, () => createEnv('awards')); | ||
|
||
const apiRouter = Router(); | ||
apiRouter.use('/catalog', await catalog(catalogEnv)); | ||
apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv)); | ||
apiRouter.use('/auth', await auth(authEnv)); | ||
apiRouter.use('/techdocs', await techdocs(techdocsEnv)); | ||
apiRouter.use('/proxy', await proxy(proxyEnv)); | ||
apiRouter.use('/search', await search(searchEnv)); | ||
apiRouter.use('/awards', await awards(awardsEnv)); | ||
|
||
// Add backends ABOVE this line; this 404 handler is the catch-all fallback | ||
apiRouter.use(notFoundHandler()); | ||
|
||
const service = createServiceBuilder(module) | ||
.loadConfig(config) | ||
.addRouter('/api', apiRouter) | ||
.addRouter('', await app(appEnv)); | ||
|
||
await service.start().catch(err => { | ||
console.log(err); | ||
process.exit(1); | ||
}); | ||
} | ||
|
||
module.hot?.accept(); | ||
main().catch(error => { | ||
console.error('Backend failed to start up', error); | ||
process.exit(1); | ||
}); | ||
import { createBackend } from '@backstage/backend-defaults'; | ||
|
||
const backend = createBackend(); | ||
|
||
backend.add(import('@backstage/plugin-app-backend/alpha')); | ||
backend.add(import('@backstage/plugin-proxy-backend/alpha')); | ||
backend.add(import('@backstage/plugin-scaffolder-backend/alpha')); | ||
backend.add(import('@backstage/plugin-techdocs-backend/alpha')); | ||
|
||
// auth plugin | ||
backend.add(import('@backstage/plugin-auth-backend')); | ||
// See https://backstage.io/docs/backend-system/building-backends/migrating#the-auth-plugin | ||
backend.add(import('@backstage/plugin-auth-backend-module-guest-provider')); | ||
// See https://backstage.io/docs/auth/guest/provider | ||
|
||
// catalog plugin | ||
backend.add(import('@backstage/plugin-catalog-backend/alpha')); | ||
backend.add( | ||
import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'), | ||
); | ||
|
||
// See https://backstage.io/docs/features/software-catalog/configuration#subscribing-to-catalog-errors | ||
backend.add(import('@backstage/plugin-catalog-backend-module-logs')); | ||
|
||
// permission plugin | ||
backend.add(import('@backstage/plugin-permission-backend/alpha')); | ||
// See https://backstage.io/docs/permissions/getting-started for how to create your own permission policy | ||
backend.add( | ||
import('@backstage/plugin-permission-backend-module-allow-all-policy'), | ||
); | ||
|
||
// search plugin | ||
backend.add(import('@backstage/plugin-search-backend/alpha')); | ||
|
||
// search collators | ||
backend.add(import('@backstage/plugin-search-backend-module-catalog/alpha')); | ||
backend.add(import('@backstage/plugin-search-backend-module-techdocs/alpha')); | ||
|
||
backend.add(import('@seatgeek/backstage-plugin-awards-backend')); | ||
backend.start(); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.