46a8bb75884f67da0c4b2ecfc9138bff44fb7ab2
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'
6 import finalhandler
from 'finalhandler'
7 import serveStatic
from 'serve-static'
9 const isCFEnvironment
= env
.VCAP_APPLICATION
!= null
10 const PORT
= isCFEnvironment
? parseInt(env
.PORT
) : 3030
11 const uiPath
= join(dirname(fileURLToPath(import.meta
.url
)), './dist')
13 const serve
= serveStatic(uiPath
)
15 const server
= createServer((req
, res
) => serve(req
, res
, finalhandler(req
, res
)))
17 server
.listen(PORT
, () => console
.info(`Web UI running at: http://localhost:${PORT}`))