From 9a5ea983b0e3fcb3ac5a2eb7e9dc69c322354a99 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Fri, 25 Sep 2020 16:26:43 +0200 Subject: [PATCH] plugins: remove identity-backend --- .changeset/config.json | 1 - packages/backend/package.json | 1 - packages/backend/src/index.ts | 3 - packages/backend/src/plugins/identity.ts | 22 ----- .../packages/backend/package.json.hbs | 1 - .../default-app/packages/backend/src/index.ts | 3 - .../packages/backend/src/plugins/identity.ts | 6 -- plugins/identity-backend/.eslintrc.js | 3 - plugins/identity-backend/README.md | 11 --- plugins/identity-backend/package.json | 43 ---------- .../src/adapters/StaticJsonAdapter.ts | 82 ------------------- .../identity-backend/src/adapters/index.ts | 17 ---- .../identity-backend/src/adapters/types.ts | 42 ---------- .../src/adapters/userGroups.ts | 35 -------- plugins/identity-backend/src/index.test.ts | 23 ------ plugins/identity-backend/src/index.ts | 17 ---- plugins/identity-backend/src/run.ts | 33 -------- .../identity-backend/src/service/router.ts | 50 ----------- .../src/service/standaloneApplication.ts | 52 ------------ .../src/service/standaloneServer.ts | 50 ----------- plugins/identity-backend/src/setupTests.ts | 19 ----- 21 files changed, 514 deletions(-) delete mode 100644 packages/backend/src/plugins/identity.ts delete mode 100644 packages/create-app/templates/default-app/packages/backend/src/plugins/identity.ts delete mode 100644 plugins/identity-backend/.eslintrc.js delete mode 100644 plugins/identity-backend/README.md delete mode 100644 plugins/identity-backend/package.json delete mode 100644 plugins/identity-backend/src/adapters/StaticJsonAdapter.ts delete mode 100644 plugins/identity-backend/src/adapters/index.ts delete mode 100644 plugins/identity-backend/src/adapters/types.ts delete mode 100644 plugins/identity-backend/src/adapters/userGroups.ts delete mode 100644 plugins/identity-backend/src/index.test.ts delete mode 100644 plugins/identity-backend/src/index.ts delete mode 100644 plugins/identity-backend/src/run.ts delete mode 100644 plugins/identity-backend/src/service/router.ts delete mode 100644 plugins/identity-backend/src/service/standaloneApplication.ts delete mode 100644 plugins/identity-backend/src/service/standaloneServer.ts delete mode 100644 plugins/identity-backend/src/setupTests.ts diff --git a/.changeset/config.json b/.changeset/config.json index 02236339b9..c7c4f11e57 100644 --- a/.changeset/config.json +++ b/.changeset/config.json @@ -34,7 +34,6 @@ "@backstage/plugin-gitops-profiles", "@backstage/plugin-graphiql", "@backstage/plugin-graphql-backend", - "@backstage/plugin-identity-backend", "@backstage/plugin-jenkins", "@backstage/plugin-lighthouse", "@backstage/plugin-newrelic", diff --git a/packages/backend/package.json b/packages/backend/package.json index 5bfaf2ee46..3c40d03def 100644 --- a/packages/backend/package.json +++ b/packages/backend/package.json @@ -25,7 +25,6 @@ "@backstage/plugin-auth-backend": "^0.1.1-alpha.23", "@backstage/plugin-catalog-backend": "^0.1.1-alpha.23", "@backstage/plugin-graphql-backend": "^0.1.1-alpha.23", - "@backstage/plugin-identity-backend": "^0.1.1-alpha.23", "@backstage/plugin-kubernetes-backend": "^0.1.1-alpha.23", "@backstage/plugin-proxy-backend": "^0.1.1-alpha.23", "@backstage/plugin-rollbar-backend": "^0.1.1-alpha.23", diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 16cb35cade..dbd7842f8b 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -36,7 +36,6 @@ import { ConfigReader, AppConfig } from '@backstage/config'; import healthcheck from './plugins/healthcheck'; import auth from './plugins/auth'; import catalog from './plugins/catalog'; -import identity from './plugins/identity'; import kubernetes from './plugins/kubernetes'; import rollbar from './plugins/rollbar'; import scaffolder from './plugins/scaffolder'; @@ -73,7 +72,6 @@ async function main() { const catalogEnv = useHotMemoize(module, () => createEnv('catalog')); const scaffolderEnv = useHotMemoize(module, () => createEnv('scaffolder')); const authEnv = useHotMemoize(module, () => createEnv('auth')); - const identityEnv = useHotMemoize(module, () => createEnv('identity')); const proxyEnv = useHotMemoize(module, () => createEnv('proxy')); const rollbarEnv = useHotMemoize(module, () => createEnv('rollbar')); const sentryEnv = useHotMemoize(module, () => createEnv('sentry')); @@ -88,7 +86,6 @@ async function main() { apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv)); apiRouter.use('/sentry', await sentry(sentryEnv)); apiRouter.use('/auth', await auth(authEnv)); - apiRouter.use('/identity', await identity(identityEnv)); apiRouter.use('/techdocs', await techdocs(techdocsEnv)); apiRouter.use('/kubernetes', await kubernetes(kubernetesEnv)); apiRouter.use('/proxy', await proxy(proxyEnv)); diff --git a/packages/backend/src/plugins/identity.ts b/packages/backend/src/plugins/identity.ts deleted file mode 100644 index 63a326965c..0000000000 --- a/packages/backend/src/plugins/identity.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { createRouter } from '@backstage/plugin-identity-backend'; -import { PluginEnvironment } from '../types'; - -export default async function createPlugin({ logger }: PluginEnvironment) { - return await createRouter({ logger }); -} diff --git a/packages/create-app/templates/default-app/packages/backend/package.json.hbs b/packages/create-app/templates/default-app/packages/backend/package.json.hbs index b70f36650e..78c80b7ee1 100644 --- a/packages/create-app/templates/default-app/packages/backend/package.json.hbs +++ b/packages/create-app/templates/default-app/packages/backend/package.json.hbs @@ -22,7 +22,6 @@ "@backstage/config": "^{{version}}", "@backstage/plugin-auth-backend": "^{{version}}", "@backstage/plugin-catalog-backend": "^{{version}}", - "@backstage/plugin-identity-backend": "^{{version}}", "@backstage/plugin-proxy-backend": "^{{version}}", "@backstage/plugin-rollbar-backend": "^{{version}}", "@backstage/plugin-scaffolder-backend": "^{{version}}", diff --git a/packages/create-app/templates/default-app/packages/backend/src/index.ts b/packages/create-app/templates/default-app/packages/backend/src/index.ts index fa058b6f71..07f1b1c99a 100644 --- a/packages/create-app/templates/default-app/packages/backend/src/index.ts +++ b/packages/create-app/templates/default-app/packages/backend/src/index.ts @@ -19,7 +19,6 @@ import { import { ConfigReader, AppConfig } from '@backstage/config'; import auth from './plugins/auth'; import catalog from './plugins/catalog'; -import identity from './plugins/identity'; import scaffolder from './plugins/scaffolder'; import proxy from './plugins/proxy'; import techdocs from './plugins/techdocs'; @@ -51,7 +50,6 @@ async function main() { const catalogEnv = useHotMemoize(module, () => createEnv('catalog')); const scaffolderEnv = useHotMemoize(module, () => createEnv('scaffolder')); const authEnv = useHotMemoize(module, () => createEnv('auth')); - const identityEnv = useHotMemoize(module, () => createEnv('identity')); const proxyEnv = useHotMemoize(module, () => createEnv('proxy')); const techdocsEnv = useHotMemoize(module, () => createEnv('techdocs')); @@ -59,7 +57,6 @@ async function main() { apiRouter.use('/catalog', await catalog(catalogEnv)) apiRouter.use('/scaffolder', await scaffolder(scaffolderEnv)) apiRouter.use('/auth', await auth(authEnv)) - apiRouter.use('/identity', await identity(identityEnv)) apiRouter.use('/techdocs', await techdocs(techdocsEnv)) apiRouter.use('/proxy', await proxy(proxyEnv)) apiRouter.use(notFoundHandler()); diff --git a/packages/create-app/templates/default-app/packages/backend/src/plugins/identity.ts b/packages/create-app/templates/default-app/packages/backend/src/plugins/identity.ts deleted file mode 100644 index f82090eec9..0000000000 --- a/packages/create-app/templates/default-app/packages/backend/src/plugins/identity.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { createRouter } from '@backstage/plugin-identity-backend'; -import { PluginEnvironment } from '../types'; - -export default async function createPlugin({ logger }: PluginEnvironment) { - return await createRouter({ logger }); -} diff --git a/plugins/identity-backend/.eslintrc.js b/plugins/identity-backend/.eslintrc.js deleted file mode 100644 index 16a033dbc6..0000000000 --- a/plugins/identity-backend/.eslintrc.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - extends: [require.resolve('@backstage/cli/config/eslint.backend')], -}; diff --git a/plugins/identity-backend/README.md b/plugins/identity-backend/README.md deleted file mode 100644 index c95fed0698..0000000000 --- a/plugins/identity-backend/README.md +++ /dev/null @@ -1,11 +0,0 @@ -# Identity Backend - -WORK IN PROGRESS - -This is the backend part of the identity plugin. - -It responds to identity requests from the frontend. - -## Links - -- [The Backstage homepage](https://backstage.io) diff --git a/plugins/identity-backend/package.json b/plugins/identity-backend/package.json deleted file mode 100644 index 63ecb65d1e..0000000000 --- a/plugins/identity-backend/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "@backstage/plugin-identity-backend", - "version": "0.1.1-alpha.23", - "main": "src/index.ts", - "types": "src/index.ts", - "license": "Apache-2.0", - "private": false, - "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" - }, - "scripts": { - "start": "backstage-cli backend:dev", - "build": "backstage-cli backend:build", - "lint": "backstage-cli lint", - "test": "backstage-cli test", - "prepack": "backstage-cli prepack", - "postpack": "backstage-cli postpack", - "clean": "backstage-cli clean" - }, - "dependencies": { - "@backstage/backend-common": "^0.1.1-alpha.23", - "@types/express": "^4.17.6", - "compression": "^1.7.4", - "cors": "^2.8.5", - "express": "^4.17.1", - "express-promise-router": "^3.0.3", - "fs-extra": "^9.0.0", - "helmet": "^4.0.0", - "morgan": "^1.10.0", - "winston": "^3.2.1", - "yn": "^4.0.0" - }, - "devDependencies": { - "@backstage/cli": "^0.1.1-alpha.23", - "jest-fetch-mock": "^3.0.3", - "msw": "^0.20.5" - }, - "files": [ - "dist" - ] -} diff --git a/plugins/identity-backend/src/adapters/StaticJsonAdapter.ts b/plugins/identity-backend/src/adapters/StaticJsonAdapter.ts deleted file mode 100644 index 9a58da2e85..0000000000 --- a/plugins/identity-backend/src/adapters/StaticJsonAdapter.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - Group, - GroupsResponse, - IdentityApi, - GroupsRequest, - GroupsJson, -} from './types'; - -export class StaticJsonAdapter implements IdentityApi { - private readonly groups: Group[]; - - constructor(userGroups: GroupsJson) { - this.groups = userGroups.groups; - } - - getUserGroups(req: GroupsRequest): Promise { - return new Promise(resolve => { - const { user, type } = req; - const userGroups = this._getUserGroups(this.groups, user); - const groups = this.filterGroupsByType(userGroups, type); - resolve({ groups }); - }); - } - - _getUserGroups(groups: Group[], user: string) { - const userGroups: Set = new Set(); - groups.forEach(group => { - if (this.isUserInGroup(group, user)) { - userGroups.add(group); - } - - if (group.children) { - const userSubGroups = this._getUserGroups(group.children, user) ?? []; - const isUserInSubGroup = Boolean(userSubGroups.length); - if (isUserInSubGroup) { - userGroups.add(group); - } - userSubGroups.forEach(subGroup => userGroups.add(subGroup)); - } - }); - return Array.from(userGroups); - } - - private filterGroupsByType = (userGroups: Group[], type: string) => { - const groups = type - ? userGroups - .filter((group: Group) => group.type === type) - .map(group => ({ name: group.name, type: group.type })) - : userGroups.map(group => ({ - name: group.name, - type: group.type, - })); - return groups; - }; - - private isUserInGroup = (group: Group, user: string): boolean => { - if (group.members) { - const groupMembers = group.members; - const groupsWithUser = groupMembers.filter( - member => member.name === user, - ); - return Boolean(groupsWithUser.length); - } - return false; - }; -} diff --git a/plugins/identity-backend/src/adapters/index.ts b/plugins/identity-backend/src/adapters/index.ts deleted file mode 100644 index 357391a25b..0000000000 --- a/plugins/identity-backend/src/adapters/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './StaticJsonAdapter'; diff --git a/plugins/identity-backend/src/adapters/types.ts b/plugins/identity-backend/src/adapters/types.ts deleted file mode 100644 index 59fd1324d1..0000000000 --- a/plugins/identity-backend/src/adapters/types.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export type User = { - name: string; -}; - -export type Group = { - name: string; - type: string; - members?: User[]; - children?: Group[]; -}; - -export type GroupsJson = { - groups: Group[]; -}; - -export type GroupsResponse = { - groups: Group[]; -}; - -export type GroupsRequest = { - user: string; - type: string; -}; -export interface IdentityApi { - getUserGroups(req: GroupsRequest): Promise; -} diff --git a/plugins/identity-backend/src/adapters/userGroups.ts b/plugins/identity-backend/src/adapters/userGroups.ts deleted file mode 100644 index 806ca1f43f..0000000000 --- a/plugins/identity-backend/src/adapters/userGroups.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -export const userGroups = { - groups: [ - { - name: 'engineering', - type: 'org', - children: [ - { - name: 'authentication', - type: 'team', - members: [{ name: 'kent' }, { name: 'dobbs' }], - }, - { - name: 'checkout', - type: 'team', - members: [{ name: 'don' }, { name: 'abramev' }], - }, - ], - }, - ], -}; diff --git a/plugins/identity-backend/src/index.test.ts b/plugins/identity-backend/src/index.test.ts deleted file mode 100644 index 4fca4ca746..0000000000 --- a/plugins/identity-backend/src/index.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import '@backstage/backend-common'; - -describe('test', () => { - it('unbreaks the test runner', () => { - expect(true).toBeTruthy(); - }); -}); diff --git a/plugins/identity-backend/src/index.ts b/plugins/identity-backend/src/index.ts deleted file mode 100644 index 7612c392a2..0000000000 --- a/plugins/identity-backend/src/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -export * from './service/router'; diff --git a/plugins/identity-backend/src/run.ts b/plugins/identity-backend/src/run.ts deleted file mode 100644 index a2c2601258..0000000000 --- a/plugins/identity-backend/src/run.ts +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import yn from 'yn'; -import { getRootLogger } from '@backstage/backend-common'; -import { startStandaloneServer } from './service/standaloneServer'; - -const port = process.env.PLUGIN_PORT ? Number(process.env.PLUGIN_PORT) : 3003; -const enableCors = yn(process.env.PLUGIN_CORS, { default: false }); -const logger = getRootLogger(); - -startStandaloneServer({ port, enableCors, logger }).catch(err => { - logger.error(err); - process.exit(1); -}); - -process.on('SIGINT', () => { - logger.info('CTRL+C pressed; exiting.'); - process.exit(0); -}); diff --git a/plugins/identity-backend/src/service/router.ts b/plugins/identity-backend/src/service/router.ts deleted file mode 100644 index 9d16e8f332..0000000000 --- a/plugins/identity-backend/src/service/router.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import express from 'express'; -import Router from 'express-promise-router'; -import { Logger } from 'winston'; -import { StaticJsonAdapter } from '../adapters'; -import { IdentityApi } from '../adapters/types'; -import { userGroups } from '../adapters/userGroups'; - -export interface RouterOptions { - logger: Logger; -} - -const makeRouter = (adapter: IdentityApi): express.Router => { - const router = Router(); - router.use(express.json()); - - router.get('/users/:user/groups', async (req, res) => { - const user = req.params.user; - const type = req.query.type?.toString() ?? ''; - const response = await adapter.getUserGroups({ user, type }); - res.send(response); - }); - - return router; -}; - -export async function createRouter( - options: RouterOptions, -): Promise { - const logger = options.logger; - - logger.info('Initializing identity API backend'); - const adapter = new StaticJsonAdapter(userGroups); - return makeRouter(adapter); -} diff --git a/plugins/identity-backend/src/service/standaloneApplication.ts b/plugins/identity-backend/src/service/standaloneApplication.ts deleted file mode 100644 index 5eea4fb8f5..0000000000 --- a/plugins/identity-backend/src/service/standaloneApplication.ts +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { - errorHandler, - notFoundHandler, - requestLoggingHandler, -} from '@backstage/backend-common'; -import compression from 'compression'; -import cors from 'cors'; -import express from 'express'; -import helmet from 'helmet'; -import { Logger } from 'winston'; -import { createRouter } from './router'; - -export interface ApplicationOptions { - enableCors: boolean; - logger: Logger; -} - -export async function createStandaloneApplication( - options: ApplicationOptions, -): Promise { - const { enableCors, logger } = options; - const app = express(); - - app.use(helmet()); - if (enableCors) { - app.use(cors()); - } - app.use(compression()); - app.use(express.json()); - app.use(requestLoggingHandler()); - app.use('/', await createRouter({ logger })); - app.use(notFoundHandler()); - app.use(errorHandler()); - - return app; -} diff --git a/plugins/identity-backend/src/service/standaloneServer.ts b/plugins/identity-backend/src/service/standaloneServer.ts deleted file mode 100644 index 42231b45a9..0000000000 --- a/plugins/identity-backend/src/service/standaloneServer.ts +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Server } from 'http'; -import { Logger } from 'winston'; -import { createStandaloneApplication } from './standaloneApplication'; - -export interface ServerOptions { - port: number; - enableCors: boolean; - logger: Logger; -} - -export async function startStandaloneServer( - options: ServerOptions, -): Promise { - const logger = options.logger.child({ service: 'identity-backend' }); - - logger.debug('Creating application...'); - const app = await createStandaloneApplication({ - enableCors: options.enableCors, - logger, - }); - - logger.debug('Starting application server...'); - return await new Promise((resolve, reject) => { - const server = app.listen(options.port, (err?: Error) => { - if (err) { - reject(err); - return; - } - - logger.info(`Listening on port ${options.port}`); - resolve(server); - }); - }); -} diff --git a/plugins/identity-backend/src/setupTests.ts b/plugins/identity-backend/src/setupTests.ts deleted file mode 100644 index f7b6ca962d..0000000000 --- a/plugins/identity-backend/src/setupTests.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2020 Spotify AB - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -require('jest-fetch-mock').enableMocks(); - -export {};