mirror of
https://github.com/outbackdingo/openapi-ui.git
synced 2026-01-27 10:19:49 +00:00
bff integration
This commit is contained in:
1
.env
1
.env
@@ -8,3 +8,4 @@ VITE_MARKETPLACE_KIND=MarketplacePanel
|
||||
VITE_INSTANCES_API_GROUP=incloud.io
|
||||
VITE_INSTANCES_VERSION=v1alpha1
|
||||
VITE_INSTANCES_RESOURCE_NAME=v1alpha1
|
||||
VITE_BFF_URL=
|
||||
|
||||
@@ -9,3 +9,4 @@ MARKETPLACE_KIND=
|
||||
INSTANCES_API_GROUP=
|
||||
INSTANCES_VERSION=
|
||||
INSTANCES_RESOURCE_NAME=
|
||||
BFF_URL=
|
||||
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -11,7 +11,7 @@
|
||||
"@ant-design/icons": "5.6.0",
|
||||
"@monaco-editor/react": "4.6.0",
|
||||
"@originjs/vite-plugin-federation": "1.3.6",
|
||||
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.38",
|
||||
"@prorobotech/openapi-k8s-toolkit": "^0.0.1-alpha.39",
|
||||
"@readme/openapi-parser": "4.0.0",
|
||||
"@reduxjs/toolkit": "2.2.5",
|
||||
"@tanstack/react-query": "5.62.2",
|
||||
@@ -2807,9 +2807,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@prorobotech/openapi-k8s-toolkit": {
|
||||
"version": "0.0.1-alpha.38",
|
||||
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.38.tgz",
|
||||
"integrity": "sha512-frJPlCm1SWyep3YQcAGGSua94Tgrm6oqXCctkKD+29q+B2oHi05rSbSbsAmIKG3HAQrmUGbWtD3Zg8C/+RJ99g==",
|
||||
"version": "0.0.1-alpha.39",
|
||||
"resolved": "https://registry.npmjs.org/@prorobotech/openapi-k8s-toolkit/-/openapi-k8s-toolkit-0.0.1-alpha.39.tgz",
|
||||
"integrity": "sha512-goiUea/bDtE55KVvmrQ6aX1CSSSkHMM4BavO1oZmEj3uAtiPNVEJ67jqCNjxK2dWoLRKH//Neu/9tF8XrOu/0Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@monaco-editor/react": "4.6.0",
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
"@ant-design/icons": "5.6.0",
|
||||
"@monaco-editor/react": "4.6.0",
|
||||
"@originjs/vite-plugin-federation": "1.3.6",
|
||||
"@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.38",
|
||||
"@prorobotech/openapi-k8s-toolkit": "0.0.1-alpha.39",
|
||||
"@readme/openapi-parser": "4.0.0",
|
||||
"@reduxjs/toolkit": "2.2.5",
|
||||
"@tanstack/react-query": "5.62.2",
|
||||
|
||||
@@ -32,6 +32,7 @@ const INSTANCES_API_GROUP =
|
||||
const INSTANCES_VERSION = process.env.LOCAL === 'true' ? options?.INSTANCES_VERSION : process.env.INSTANCES_VERSION
|
||||
const INSTANCES_RESOURCE_NAME =
|
||||
process.env.LOCAL === 'true' ? options?.INSTANCES_RESOURCE_NAME : process.env.INSTANCES_RESOURCE_NAME
|
||||
const BFF_URL = process.env.LOCAL === 'true' ? options?.BFF_URL : process.env.BFF_URL
|
||||
|
||||
const healthcheck = require('express-healthcheck')
|
||||
const promBundle = require('express-prom-bundle')
|
||||
@@ -98,6 +99,21 @@ if (process.env.LOCAL === 'true') {
|
||||
// },
|
||||
}),
|
||||
)
|
||||
|
||||
// Proxy: /openapi-bff
|
||||
app.use(
|
||||
'/openapi-bff',
|
||||
createProxyMiddleware({
|
||||
target: BFF_URL,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
// pathRewrite: (path, req) => path.replace(/^\/bff/, ''),
|
||||
// logLevel: 'debug',
|
||||
// onProxyReq: (proxyReq, req, res) => {
|
||||
// console.debug(`[PROXY] ${req.method} ${req.originalUrl} -> ${proxyReq.getHeader('host')}${proxyReq.path}`)
|
||||
// },
|
||||
}),
|
||||
)
|
||||
} else {
|
||||
console.log('🚫 Proxies are disabled.')
|
||||
}
|
||||
|
||||
16
src/App.tsx
16
src/App.tsx
@@ -4,8 +4,6 @@ import React, { FC, useEffect } from 'react'
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
||||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
||||
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
||||
import { dereference } from '@readme/openapi-parser'
|
||||
import { OpenAPIV2 } from 'openapi-types'
|
||||
import { ConfigProvider, theme as antdtheme } from 'antd'
|
||||
import { getSwagger } from '@prorobotech/openapi-k8s-toolkit'
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
@@ -62,19 +60,9 @@ export const App: FC<TAppProps> = ({ isFederation, forcedTheme }) => {
|
||||
}
|
||||
getSwagger({ clusterName: cluster })
|
||||
.then(({ data }) => {
|
||||
dereference(data, {
|
||||
dereference: {
|
||||
circular: 'ignore',
|
||||
},
|
||||
})
|
||||
.then(data => {
|
||||
// deference is a cruel thing
|
||||
dispatch(setSwagger(data as OpenAPIV2.Document))
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('Swagger: deref error', error)
|
||||
})
|
||||
dispatch(setSwagger(data))
|
||||
})
|
||||
|
||||
.catch(error => {
|
||||
console.log('Swagger: fetch error', error)
|
||||
})
|
||||
|
||||
@@ -78,6 +78,12 @@ export default defineConfig({
|
||||
secure: false,
|
||||
rewrite: path => path.replace(/^\/clusterlist/, ''),
|
||||
},
|
||||
'/openapi-bff': {
|
||||
target: options?.BFF_URL,
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
// rewrite: path => path.replace(/^\/bff/, ''),
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user