import { startServer } from "@workshop/http"
This commit is contained in:
parent
c2fbeef6e5
commit
0f3bc47164
|
|
@ -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 }
|
||||
Loading…
Reference in New Issue
Block a user