X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=ui%2Fweb%2Fstart.js;h=39cdf0f446d338a700f2f22763ff2193b3d2187f;hb=cbaa683986beae870b1a98570b39dbfb030b52db;hp=ed6e3e01ff65c0f81696ba9805a5b622f8c5169c;hpb=ebbfbf1c01e010d051956867484b74a94237f546;p=e-mobility-charging-stations-simulator.git diff --git a/ui/web/start.js b/ui/web/start.js index ed6e3e01..39cdf0f4 100644 --- a/ui/web/start.js +++ b/ui/web/start.js @@ -1,15 +1,17 @@ -const path = require('path'), - finalhandler = require('finalhandler'), - http = require('http'), - serveStatic = require('serve-static'); +import { createServer } from 'node:http'; +import { dirname, join } from 'node:path'; +import { env } from 'node:process'; +import { fileURLToPath } from 'node:url'; +import finalhandler from 'finalhandler'; +import serveStatic from 'serve-static'; -const isCFEnvironment = process.env.VCAP_APPLICATION !== undefined, - PORT = isCFEnvironment ? parseInt(process.env.PORT) : 3030, - uiPath = path.join(__dirname, './dist'); +const isCFEnvironment = env.VCAP_APPLICATION !== undefined, + PORT = isCFEnvironment ? parseInt(env.PORT) : 3030, + uiPath = join(dirname(fileURLToPath(import.meta.url)), './dist'); const serve = serveStatic(uiPath); -const server = http.createServer(function onRequest(req, res) { +const server = createServer(function onRequest(req, res) { serve(req, res, finalhandler(req, res)); });