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