30 lines
606 B
TypeScript
30 lines
606 B
TypeScript
import index from './index.html'
|
|
|
|
const server = Bun.serve({
|
|
port: process.env.PORT ? Number(process.env.PORT) : 3001,
|
|
routes: {
|
|
'/*': index,
|
|
|
|
'/api/hello': {
|
|
async GET(req) {
|
|
return Response.json({
|
|
message: 'Hello, world!',
|
|
method: 'GET',
|
|
})
|
|
},
|
|
async PUT(req) {
|
|
return Response.json({
|
|
message: 'Hello, world!',
|
|
method: 'PUT',
|
|
})
|
|
},
|
|
},
|
|
},
|
|
development: process.env.NODE_ENV !== 'production' && {
|
|
hmr: true,
|
|
console: true,
|
|
},
|
|
})
|
|
|
|
console.log(`🚀 Server running at ${server.url}`)
|