Merge pull request #1 from Nek/feat/proxy-devserver
feat: move proxy to devserver
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "yarn workspace example-app start",
|
||||
"start:backend": "yarn workspace example-backend start",
|
||||
"bundle": "yarn build && yarn workspace example-app bundle",
|
||||
"build": "lerna run build",
|
||||
"clean": "lerna run clean",
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"@testing-library/cypress": "^6.0.0",
|
||||
"@types/jquery": "^3.3.34",
|
||||
"@testing-library/jest-dom": "^4.2.4",
|
||||
"@testing-library/react": "^9.3.2",
|
||||
"@testing-library/user-event": "^7.1.2",
|
||||
@@ -15,13 +14,13 @@
|
||||
"cross-env": "^7.0.0",
|
||||
"cypress": "^4.2.0",
|
||||
"eslint-plugin-cypress": "^2.10.3",
|
||||
"http-proxy-middleware": "^1.0.3",
|
||||
"start-server-and-test": "^1.10.11"
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/cli": "^0.1.1-alpha.4",
|
||||
"@backstage/core": "^0.1.1-alpha.4",
|
||||
"@backstage/plugin-circleci": "^0.1.1-alpha.4",
|
||||
"@backstage/plugin-circleci-backend": "^0.1.1-alpha.4",
|
||||
"@backstage/plugin-home-page": "^0.1.1-alpha.4",
|
||||
"@backstage/plugin-inventory": "^0.1.1-alpha.4",
|
||||
"@backstage/plugin-lighthouse": "^0.1.1-alpha.4",
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const { proxySettings } = require('@backstage/plugin-circleci');
|
||||
const { createProxyMiddleware } = require('http-proxy-middleware');
|
||||
|
||||
module.exports = (/** @type {import('express').Application} */ app) =>
|
||||
Object.entries(proxySettings).forEach(([url, settings]) =>
|
||||
app.use(url, createProxyMiddleware(settings)),
|
||||
);
|
||||
@@ -16,7 +16,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@backstage/plugin-inventory-backend": "0.1.1-alpha.4",
|
||||
"@backstage/plugin-circleci-backend": "0.1.1-alpha.4",
|
||||
"compression": "^1.7.4",
|
||||
"cors": "^2.8.5",
|
||||
"express": "^4.17.1",
|
||||
|
||||
@@ -28,7 +28,6 @@ import helmet from 'helmet';
|
||||
import compression from 'compression';
|
||||
import { testRouter } from './test';
|
||||
import { router as inventoryRouter } from '@backstage/plugin-inventory-backend';
|
||||
import { router as circleCIRouter } from '@backstage/plugin-circleci-backend';
|
||||
|
||||
const DEFAULT_PORT = 7000;
|
||||
|
||||
@@ -41,7 +40,6 @@ app.use(compression());
|
||||
app.use(express.json());
|
||||
app.use('/test', testRouter);
|
||||
app.use('/inventory', inventoryRouter);
|
||||
app.use('/circleci', circleCIRouter);
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Listening on port ${PORT}`);
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
module.exports = {
|
||||
extends: [require.resolve('@backstage/cli/config/eslint')],
|
||||
};
|
||||
@@ -1,6 +0,0 @@
|
||||
# Title
|
||||
Welcome to the circleci-backend plugin!
|
||||
|
||||
## Sub-section 1
|
||||
|
||||
## Sub-section 2
|
||||
@@ -1,23 +0,0 @@
|
||||
{
|
||||
"name": "@backstage/plugin-circleci-backend",
|
||||
"version": "0.1.1-alpha.4",
|
||||
"main": "dist",
|
||||
"license": "Apache-2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"lint": "backstage-cli lint",
|
||||
"test": "backstage-cli test",
|
||||
"clean": "backstage-cli clean"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@backstage/cli": "^0.1.1-alpha.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.17.1",
|
||||
"http-proxy-middleware": "^1.0.3"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
]
|
||||
}
|
||||
@@ -1,27 +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 httpProxy from 'http-proxy';
|
||||
|
||||
// Simple proxy for handling CORS for now
|
||||
const proxy = httpProxy.createServer({
|
||||
target: 'https://circleci.com/api/v1.1',
|
||||
changeOrigin: true,
|
||||
});
|
||||
proxy.on('error', e => console.error(e));
|
||||
export const router = express();
|
||||
router.use('/api', (req, res) => proxy.web(req, res));
|
||||
@@ -1,15 +0,0 @@
|
||||
{
|
||||
"include": ["src"],
|
||||
"compilerOptions": {
|
||||
"baseUrl": "src",
|
||||
"outDir": "dist",
|
||||
"incremental": true,
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"strict": true,
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"esModuleInterop": true,
|
||||
"types": ["node", "jest"]
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import { CircleCI, GitType, CircleCIOptions } from 'circleci-api';
|
||||
import { ApiRef } from '@backstage/core';
|
||||
|
||||
const defaultOptions: Partial<CircleCIOptions> = {
|
||||
circleHost: 'http://backstage.localhost:7000/circleci/api',
|
||||
circleHost: '/circleci/api',
|
||||
vcs: {
|
||||
type: GitType.GITHUB,
|
||||
owner: 'CircleCITest3',
|
||||
|
||||
@@ -16,3 +16,4 @@
|
||||
|
||||
export { plugin } from './plugin';
|
||||
export * from './api';
|
||||
export * from './proxy';
|
||||
|
||||
@@ -15,10 +15,12 @@
|
||||
*/
|
||||
import { createPlugin } from '@backstage/core';
|
||||
import { CircleCIPage } from './components/CircleCIPage';
|
||||
import { SettingsPage } from './components/SettingsPage';
|
||||
|
||||
export const plugin = createPlugin({
|
||||
id: 'circleci',
|
||||
register({ router }) {
|
||||
router.registerRoute('/circleci', CircleCIPage, { exact: false });
|
||||
router.registerRoute('/circleci', CircleCIPage);
|
||||
router.registerRoute('/circleci/settings', SettingsPage);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import type {Options} from 'http-proxy-middleware';
|
||||
|
||||
export const proxySettings: Record<string, Options> = {
|
||||
'/circleci/api': {
|
||||
target: 'https://circleci.com/api/v1.1',
|
||||
changeOrigin: true,
|
||||
logLevel: 'debug',
|
||||
pathRewrite: {
|
||||
'^/circleci/api/': '/',
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -4072,13 +4072,6 @@
|
||||
dependencies:
|
||||
"@types/sizzle" "*"
|
||||
|
||||
"@types/jquery@^3.3.34":
|
||||
version "3.3.34"
|
||||
resolved "https://registry.npmjs.org/@types/jquery/-/jquery-3.3.34.tgz#0d3b94057063d3854adaeb579652048fec07ba6c"
|
||||
integrity sha512-lW9vsVL53Xu/Nj4gi2hNmHGc4u3KKghjqTkAlO0kF5GIOPxbqqnQpgqJBzmn3yXLrPqHb6cmNJ6URnS23Vtvbg==
|
||||
dependencies:
|
||||
"@types/sizzle" "*"
|
||||
|
||||
"@types/js-cookie@2.2.5":
|
||||
version "2.2.5"
|
||||
resolved "https://registry.npmjs.org/@types/js-cookie/-/js-cookie-2.2.5.tgz#38dfaacae8623b37cc0b0d27398e574e3fc28b1e"
|
||||
|
||||
Reference in New Issue
Block a user