- Fixed Confluence API authentication using Basic auth with email - Added /wiki path to API URL for proper endpoint - Improved HTML parsing with cheerio for better table extraction - Made all table columns sortable (previously only 4 were clickable) - Removed fallback to mock data - now always uses real Confluence data - Only color Boja column instead of entire rows for cleaner look - Added proper error handling and logging
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
import { defineConfig, loadEnv } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
// Dynamic import to avoid TypeScript issues
|
|
async function getConfluenceData(env: any) {
|
|
const { fetchFromConfluence } = await import('./src/server/confluence.js')
|
|
return fetchFromConfluence(env)
|
|
}
|
|
|
|
export default defineConfig(({ mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), '')
|
|
|
|
return {
|
|
plugins: [
|
|
react(),
|
|
{
|
|
name: 'api-middleware',
|
|
configureServer(server) {
|
|
server.middlewares.use('/api/filaments', async (req, res, next) => {
|
|
if (req.method !== 'GET') {
|
|
res.statusCode = 405
|
|
res.end('Method not allowed')
|
|
return
|
|
}
|
|
|
|
try {
|
|
const filaments = await getConfluenceData(env)
|
|
res.setHeader('Content-Type', 'application/json')
|
|
res.setHeader('Cache-Control', 'max-age=300')
|
|
res.end(JSON.stringify(filaments))
|
|
} catch (error) {
|
|
console.error('API Error:', error)
|
|
res.statusCode = 500
|
|
res.setHeader('Content-Type', 'application/json')
|
|
res.end(JSON.stringify({
|
|
error: 'Failed to fetch filaments',
|
|
message: error instanceof Error ? error.message : 'Unknown error'
|
|
}))
|
|
}
|
|
})
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}) |