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