Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
  • Loading branch information
marcel-hofer authored and andi34 committed Mar 20, 2022
1 parent 8f94593 commit 5f5dab5
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/js/remotebuzzer_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,24 @@ function photoboothAction(type) {
}

/* CONFIGURE HTTP ENDPOINTS */
const requestListener = function(req, res) {
const requestListener = function (req, res) {
function sendText(content, contentType) {
res.setHeader("Content-Type", contentType || "text/plain");
res.setHeader('Content-Type', contentType || 'text/plain');
res.writeHead(200);
res.end(content);
}

switch (req.url) {
case '/':
log('http: GET /');
sendText(`<h1>Trigger Endpoints</h1>
sendText(
`<h1>Trigger Endpoints</h1>
<ul>
<li>Trigger photo: <a href="${baseUrl}/commands/start-picture" target="_blank">${baseUrl}/commands/start-picture</a></li>
<li>Trigger collage: <a href="${baseUrl}/commands/start-collage" target="_blank">${baseUrl}/commands/start-collage</a></li>
</ul>`, 'text/html');
</ul>`,
'text/html'
);
break;
case '/commands/start-picture':
log('http: GET /commands/start-picture');
Expand Down Expand Up @@ -146,10 +149,11 @@ const requestListener = function(req, res) {
}
};

const http = require('http').Server(requestListener);
const http = require('http');
const server = new http.Server(requestListener);

/* CONFIGURE WEBSOCKET SERVER */
const ioServer = require('socket.io')(http, {
const ioServer = require('socket.io')(server, {
cors: {
origin: '*',
methods: ['GET', 'POST']
Expand Down Expand Up @@ -204,7 +208,7 @@ ioServer.on('connection', function (client) {
});

/* STARTUP COMPLETED */
http.listen(config.remotebuzzer.port, () => {
server.listen(config.remotebuzzer.port, () => {
log('socket.io server started');
});

Expand Down

0 comments on commit 5f5dab5

Please sign in to comment.