| 1 | import Bootstrap from '../charging-station/Bootstrap'; |
| 2 | import express from 'express'; |
| 3 | |
| 4 | const app = express(); |
| 5 | |
| 6 | app.get('/', (request, response) => { |
| 7 | response.send(` |
| 8 | |
| 9 | |
| 10 | <form> |
| 11 | <input type="button" onclick="window.location.href='/start';" value="Start" /> |
| 12 | <input type="button" onclick="window.location.href='/stop';" value="Stop" /> |
| 13 | </form> |
| 14 | |
| 15 | `); |
| 16 | }); |
| 17 | |
| 18 | app.get('/start', (request, response, next) => { |
| 19 | Bootstrap.getInstance().start().catch(next); |
| 20 | console.log('*** started'); |
| 21 | response.send('<b>Started</b><br/><a href="/">Return to Top</a>'); |
| 22 | }); |
| 23 | |
| 24 | app.get('/stop', (request, response, next) => { |
| 25 | Bootstrap.getInstance().stop().catch(next); |
| 26 | console.log('*** stopped'); |
| 27 | response.send('<b>Stopped</b><br/><a href="/">Return to Top</a>'); |
| 28 | }); |
| 29 | |
| 30 | app.listen(process.env.PORT ?? 8080, () => |
| 31 | console.log(`Listening on port: ${process.env.PORT ?? 8080}`) |
| 32 | ); |