| 1 | import finalhandler from 'finalhandler' |
| 2 | import { createServer } from 'node:http' |
| 3 | import { dirname, join } from 'node:path' |
| 4 | import { env } from 'node:process' |
| 5 | import { fileURLToPath } from 'node:url' |
| 6 | import serveStatic from 'serve-static' |
| 7 | |
| 8 | const isCFEnvironment = env.VCAP_APPLICATION != null |
| 9 | const PORT = isCFEnvironment ? Number.parseInt(env.PORT) : 3030 |
| 10 | const uiPath = join(dirname(fileURLToPath(import.meta.url)), './dist') |
| 11 | |
| 12 | const serve = serveStatic(uiPath) |
| 13 | |
| 14 | const server = createServer((req, res) => serve(req, res, finalhandler(req, res))) |
| 15 | |
| 16 | server.listen(PORT, () => console.info(`Web UI running at: http://localhost:${PORT}`)) |