import { startServer } from "@workshop/http"

This commit is contained in:
Chris Wanstrath 2025-06-19 20:43:54 -07:00
parent c2fbeef6e5
commit 0f3bc47164

View File

@ -2,15 +2,27 @@ import { serve } from "bun"
import { nanoRemix } from "@workshop/nano-remix"
import { join } from "node:path"
const server = serve({
routes: {
"/*": (req) => nanoRemix(req, { routesDir: join(import.meta.dir, "routes") }),
},
type StartOptions = {
routesDir?: string
}
development: process.env.NODE_ENV !== "production" && {
hmr: true,
console: true,
},
})
function startServer(opts: StartOptions) {
const server = serve({
routes: {
"/*": (req) => nanoRemix(req, opts),
},
console.log(`🤖 Server running at ${server.url}`)
development: process.env.NODE_ENV !== "production" && {
hmr: true,
console: true,
},
})
console.log(`🤖 Server running at ${server.url}`)
}
if (import.meta.main) {
startServer({ routesDir: join(import.meta.dir, "routes") })
}
export { startServer }