server.ts raw

   1  import { serve } from 'bun';
   2  import api from './api';
   3  import { refreshAllOffices } from './lib/couriers';
   4  
   5  const PORT = parseInt(process.env.API_PORT || '3001');
   6  const HOST = process.env.HOST || '127.0.0.1';
   7  
   8  serve({
   9    hostname: HOST,
  10    port: PORT,
  11    fetch: api.fetch,
  12  });
  13  
  14  console.log(`API server running on http://${HOST}:${PORT}`);
  15  
  16  // best-effort background office sync
  17  refreshAllOffices()
  18    .then((n) => console.log(`courier offices synced: econt=${n.econt} speedy=${n.speedy}`))
  19    .catch((e) => console.warn(`courier sync skipped: ${e.message}`));
  20