Files
wehub-resource-sync bb5c75ce05
Component Security Validation / Security Audit (push) Waiting to run
Deploy to Cloudflare Pages / deploy (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 12:38:58 +08:00

46 lines
1.5 KiB
JavaScript

const express = require('express');
const path = require('path');
const app = express();
const port = 3001;
// Serve static files from docs directory
app.use(express.static('docs'));
// Handle filter routes - redirect to index.html
const filterRoutes = ['agents', 'commands', 'settings', 'hooks', 'mcps', 'templates'];
filterRoutes.forEach(filter => {
app.get(`/${filter}`, (req, res) => {
res.sendFile(path.join(__dirname, 'docs', 'index.html'));
});
});
// Handle component routes
app.get('/component/:type/:name', (req, res) => {
res.sendFile(path.join(__dirname, 'docs', 'component.html'));
});
// Handle blog routes
app.get('/blog/*', (req, res) => {
const blogPath = req.path.replace('/blog', '');
res.sendFile(path.join(__dirname, 'docs', 'blog', blogPath, 'index.html'), (err) => {
if (err) {
res.status(404).send('Blog post not found');
}
});
});
// Default route
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'docs', 'index.html'));
});
app.listen(port, () => {
console.log(`Development server running at http://localhost:${port}`);
console.log('Testing URLs:');
console.log(`- http://localhost:${port}/ (agents)`);
console.log(`- http://localhost:${port}/mcps`);
console.log(`- http://localhost:${port}/commands`);
console.log(`- http://localhost:${port}/settings`);
console.log(`- http://localhost:${port}/hooks`);
console.log(`- http://localhost:${port}/templates`);
});