Monorepo for Wisp.place. A static site hosting service built on top of the AT Protocol.
1import { serve } from 'bun'; 2import app from './server'; 3import { FirehoseWorker } from './lib/firehose'; 4import { mkdirSync, existsSync } from 'fs'; 5 6const PORT = process.env.PORT || 3001; 7const CACHE_DIR = './cache/sites'; 8 9// Ensure cache directory exists 10if (!existsSync(CACHE_DIR)) { 11 mkdirSync(CACHE_DIR, { recursive: true }); 12 console.log('Created cache directory:', CACHE_DIR); 13} 14 15// Start firehose worker 16const firehose = new FirehoseWorker((msg, data) => { 17 console.log(msg, data); 18}); 19 20firehose.start(); 21 22// Add health check endpoint 23app.get('/health', (c) => { 24 const firehoseHealth = firehose.getHealth(); 25 return c.json({ 26 status: 'ok', 27 firehose: firehoseHealth, 28 }); 29}); 30 31// Start HTTP server 32const server = serve({ 33 port: PORT, 34 fetch: app.fetch, 35}); 36 37console.log(` 38Wisp Hosting Service 39 40Server: http://localhost:${PORT} 41Health: http://localhost:${PORT}/health 42Cache: ${CACHE_DIR} 43Firehose: Connected to Jetstream 44`); 45 46// Graceful shutdown 47process.on('SIGINT', () => { 48 console.log('\n🛑 Shutting down...'); 49 firehose.stop(); 50 server.stop(); 51 process.exit(0); 52}); 53 54process.on('SIGTERM', () => { 55 console.log('\n🛑 Shutting down...'); 56 firehose.stop(); 57 server.stop(); 58 process.exit(0); 59});