import { serve } from "bun"
import { nanoRemix } from "@workshop/nano-remix"
import { join } from "node:path"

const server = serve({
  port: parseInt(process.env.PORT || "3000"),
  routes: {
    "/*": (req) => {
      const routesDir = join(import.meta.dir, "routes")
      return nanoRemix(req, { routesDir })
    },
  },

  development: process.env.NODE_ENV !== "production" && {
    hmr: true,
    console: true,
  },
})

console.log(`Werewolf running at ${server.url}:${server.port}`)
