build(deps-dev): apply updates
[e-mobility-charging-stations-simulator.git] / ui / web / start.js
CommitLineData
66a7748d
JB
1import { createServer } from 'node:http'
2import { dirname, join } from 'node:path'
3import { env } from 'node:process'
4import { fileURLToPath } from 'node:url'
84ec8d34 5
66a7748d
JB
6import finalhandler from 'finalhandler'
7import serveStatic from 'serve-static'
32de5a57 8
a807045b 9const isCFEnvironment = env.VCAP_APPLICATION != null
48847bc0 10const PORT = isCFEnvironment ? Number.parseInt(env.PORT) : 3030
66a7748d 11const uiPath = join(dirname(fileURLToPath(import.meta.url)), './dist')
32de5a57 12
66a7748d 13const serve = serveStatic(uiPath)
32de5a57 14
276e05ae 15const server = createServer((req, res) => serve(req, res, finalhandler(req, res)))
32de5a57 16
f80e9e18 17server.listen(PORT, () => console.info(`Web UI running at: http://localhost:${PORT}`))