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