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' | |
84ec8d34 | 5 | |
66a7748d JB |
6 | import finalhandler from 'finalhandler' |
7 | import serveStatic from 'serve-static' | |
32de5a57 | 8 | |
a807045b | 9 | const isCFEnvironment = env.VCAP_APPLICATION != null |
66a7748d JB |
10 | const PORT = isCFEnvironment ? parseInt(env.PORT) : 3030 |
11 | const uiPath = join(dirname(fileURLToPath(import.meta.url)), './dist') | |
32de5a57 | 12 | |
66a7748d | 13 | const serve = serveStatic(uiPath) |
32de5a57 | 14 | |
276e05ae | 15 | const server = createServer((req, res) => serve(req, res, finalhandler(req, res))) |
32de5a57 | 16 | |
f80e9e18 | 17 | server.listen(PORT, () => console.info(`Web UI running at: http://localhost:${PORT}`)) |