Skip to content

Commit 076c5b7

Browse files
arcestiaSkiddle-Git
authored andcommitted
feat(stats): add SEO improvements
- Add canonical URL for stats page - Integrate Tailwind CSS for styling - Add JSON-LD structured data for better search indexing
1 parent 3748238 commit 076c5b7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ app.use('*', async (c, next) => {
7676
})
7777

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

8586
// Rate limiting middleware
8687
async function checkRateLimit(c: Context<Bindings>, ip: string, domainCount: number): Promise<{ allowed: boolean, remaining: number, resetTime?: Date }> {
@@ -286,6 +287,15 @@ const statsHtml = `<!DOCTYPE html>
286287
// Load stats immediately and refresh every 30 seconds
287288
loadStats();
288289
setInterval(loadStats, 30000);
290+
291+
// Periodically update stats on the server
292+
setInterval(async () => {
293+
try {
294+
await fetch('/stats/update');
295+
} catch (error) {
296+
console.error('Error updating stats:', error);
297+
}
298+
}, 60000); // Every 60 seconds
289299
</script>
290300
</body>
291301
</html>`

0 commit comments

Comments
 (0)