- Change from server-side rendering to static export - Fetch data at build time and save as JSON - Remove API routes and tests, use static JSON file - Switch back to WEB platform from WEB_COMPUTE - Update build test for static export - Exclude out directory from security scan - Much simpler and more reliable approach
36 lines
999 B
JavaScript
36 lines
999 B
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { fetchFromConfluence } = require('../src/server/confluence.ts');
|
|
|
|
async function fetchData() {
|
|
console.log('Fetching data from Confluence...');
|
|
|
|
const env = {
|
|
CONFLUENCE_API_URL: process.env.CONFLUENCE_API_URL,
|
|
CONFLUENCE_TOKEN: process.env.CONFLUENCE_TOKEN,
|
|
CONFLUENCE_PAGE_ID: process.env.CONFLUENCE_PAGE_ID
|
|
};
|
|
|
|
try {
|
|
const data = await fetchFromConfluence(env);
|
|
|
|
// Create public directory if it doesn't exist
|
|
const publicDir = path.join(__dirname, '..', 'public');
|
|
if (!fs.existsSync(publicDir)) {
|
|
fs.mkdirSync(publicDir, { recursive: true });
|
|
}
|
|
|
|
// Write data to public directory
|
|
fs.writeFileSync(
|
|
path.join(publicDir, 'data.json'),
|
|
JSON.stringify(data, null, 2)
|
|
);
|
|
|
|
console.log(`✅ Fetched ${data.length} filaments`);
|
|
} catch (error) {
|
|
console.error('❌ Failed to fetch data:', error.message);
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
fetchData(); |