import app from './app'
import {env} from './env'
import {startReminderWorker} from './jobs/reminders'

// the dev routes mint sessions for any email and expose destructive seeding;
// refuse to boot a production process that asks for them at all
if (env.DEV_ROUTES && env.NODE_ENV === 'production')
  throw new Error('DEV_ROUTES must not be enabled in production')

startReminderWorker()

export default {
  port: env.PORT,
  fetch: (req: Request, server: Bun.Server<unknown>) =>
    app.fetch(req, {ip: server.requestIP(req)?.address ?? null}),
}
