Use eslint extension for import sorting instead of unmaintained external ones
[e-mobility-charging-stations-simulator.git] / src / ui / httpd / start.ts
index 28396dfcc9181a4ad0a8cbcf01ab6ce430ff1ba3..116b91741a9732232c9ba13a711b60b06cca6e34 100644 (file)
@@ -1,31 +1,47 @@
-import Bootstrap from '../../charging-station/Bootstrap';
 import express from 'express';
 
-const app = express();
+import Bootstrap from '../../charging-station/Bootstrap';
 
-app.get('/', (request, response) => {
-  response.send(`
+const pageHeader = `
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+"http://www.w3.org/TR/html4/strict.dtd">
+<html>
+<head>
+</head>`;
+const pageFooter = '</html>';
 
-  <form>
-    <input type="button" onclick="window.location.href='/start';" value="Start" />
-    <input type="button" onclick="window.location.href='/stop';" value="Stop" />
-  </form>
+const app = express();
+app.disable('x-powered-by');
 
-  `);
+app.get('/', (request, response) => {
+  response.send(
+    pageHeader +
+      `<body>
+       <form>
+         <input type="button" onclick="window.location.href='/start';" value="Start" />
+         <input type="button" onclick="window.location.href='/stop';" value="Stop" />
+       </form>
+       </body>` +
+      pageFooter
+  );
 });
 
 app.get('/start', (request, response, next) => {
   Bootstrap.getInstance().start().catch(next);
-  console.log('*** started');
-  response.send('<b>Started</b><br/><a href="/">Return to Top</a>');
+  console.info('*** started');
+  response.send(
+    pageHeader + '<body><b>Started</b><br/><a href="/">Return to Top</a></body>' + pageFooter
+  );
 });
 
 app.get('/stop', (request, response, next) => {
   Bootstrap.getInstance().stop().catch(next);
-  console.log('*** stopped');
-  response.send('<b>Stopped</b><br/><a href="/">Return to Top</a>');
+  console.info('*** stopped');
+  response.send(
+    pageHeader + '<body><b>Stopped</b><br/><a href="/">Return to Top</a></body>' + pageFooter
+  );
 });
 
 app.listen(process.env.PORT ?? 8080, () =>
-  console.log(`Listening on port: ${process.env.PORT ?? 8080}`)
+  console.info(`Listening on http://localhost:${process.env.PORT ?? 8080}`)
 );