Skip to content

Commit

Permalink
feat(stats): add SEO improvements
Browse files Browse the repository at this point in the history
- Add canonical URL for stats page
- Integrate Tailwind CSS for styling
- Add JSON-LD structured data for better search indexing
  • Loading branch information
arcestia authored and Skiddle-Git committed Dec 27, 2024
1 parent 3748238 commit 076c5b7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,12 @@ app.use('*', async (c, next) => {
})

// Periodically write stats to KV store
setInterval(async () => {
app.get('/stats/update', async (c) => {
if (statsCache) {
await c.env.STATS_STORE.put('global_stats', JSON.stringify(statsCache))
}
}, 60000) // Every 60 seconds
return c.json({ message: 'Stats updated' })
})

// Rate limiting middleware
async function checkRateLimit(c: Context<Bindings>, ip: string, domainCount: number): Promise<{ allowed: boolean, remaining: number, resetTime?: Date }> {
Expand Down Expand Up @@ -286,6 +287,15 @@ const statsHtml = `<!DOCTYPE html>
// Load stats immediately and refresh every 30 seconds
loadStats();
setInterval(loadStats, 30000);
// Periodically update stats on the server
setInterval(async () => {
try {
await fetch('/stats/update');
} catch (error) {
console.error('Error updating stats:', error);
}
}, 60000); // Every 60 seconds
</script>
</body>
</html>`
Expand Down

0 comments on commit 076c5b7

Please sign in to comment.