Skip to content

Commit aef63a6

Browse files
committed
prettier
1 parent 596bcfe commit aef63a6

File tree

11 files changed

+550
-532
lines changed

11 files changed

+550
-532
lines changed

Diff for: .github/ISSUE_TEMPLATE/bug-report.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ about: Create a report to help us improve
44
title: ''
55
labels: ''
66
assignees: ''
7-
87
---
98

109
**Describe the bug**
1110
A clear and concise description of what the bug is.
1211

1312
**To Reproduce**
1413
Steps to reproduce the behavior:
14+
1515
1. Go to '...'
1616
2. Click on '....'
1717
3. Scroll down to '....'
@@ -24,8 +24,9 @@ A clear and concise description of what you expected to happen.
2424
If applicable, add screenshots to help explain your problem.
2525

2626
**Desktop (please complete the following information):**
27-
- OS: [e.g. MacOS, Windows]
28-
- Version [e.g. 22]
27+
28+
- OS: [e.g. MacOS, Windows]
29+
- Version [e.g. 22]
2930

3031
** Beacon devices in use:**
3132
blink(1), luxafor-flag, etc.

Diff for: .github/ISSUE_TEMPLATE/feature-request.md

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ about: Suggest an idea for this project
44
title: 'Feature Request: '
55
labels: enhancement
66
assignees: josephdadams
7-
87
---
98

109
**Is your feature request related to a problem? Please describe.**

Diff for: .prettierrc

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"printWidth": 120,
5+
"semi": false,
6+
"singleQuote": true,
7+
"useTabs": true,
8+
"endOfLine": "lf"
9+
}

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ Built with [Electron](https://electronjs.org).
2121
```
2222
$ npm install
2323
$ npm start
24-
```
24+
```

Diff for: api.js

+61-61
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,104 @@
1-
const express = require('express');
2-
const http = require('http');
3-
const socketio = require('socket.io');
1+
const express = require('express')
2+
const http = require('http')
3+
const socketio = require('socket.io')
44

5-
const util = require('./util.js');
6-
const config = require('./config.js');
5+
const util = require('./util.js')
6+
const config = require('./config.js')
77

8-
const package_json = require('./package.json');
9-
const VERSION = package_json.version;
8+
const package_json = require('./package.json')
9+
const VERSION = package_json.version
1010

11-
var server = null;
12-
var httpServer = null;
13-
var io = null;
11+
var server = null
12+
var httpServer = null
13+
var io = null
1414

1515
class API {
1616
static start(port) {
1717
//starts the REST API
18-
server = express();
18+
server = express()
1919

20-
httpServer = new http.Server(server);
21-
io = new socketio.Server(httpServer, { allowEIO3: true });
20+
httpServer = new http.Server(server)
21+
io = new socketio.Server(httpServer, { allowEIO3: true })
2222

23-
server.use(express.json()); //parse json in body
23+
server.use(express.json()) //parse json in body
2424

2525
server.get('/version', function (req, res) {
26-
res.send({version: VERSION});
27-
});
26+
res.send({ version: VERSION })
27+
})
2828

2929
server.get('/control_status', function (req, res) {
30-
res.send({control_status: config.get('allowControl')});
31-
});
30+
res.send({ control_status: config.get('allowControl') })
31+
})
3232

3333
server.get('/devices', function (req, res) {
34-
res.send({devices: util.getDevices()});
35-
});
34+
res.send({ devices: util.getDevices() })
35+
})
3636

3737
server.get('/colors', function (req, res) {
38-
res.send({colors: util.getColors()});
39-
});
38+
res.send({ colors: util.getColors() })
39+
})
4040

4141
server.get('/sounds', function (req, res) {
42-
res.send({sounds: util.getSounds()});
43-
});
42+
res.send({ sounds: util.getSounds() })
43+
})
4444

4545
server.post('/beacon', function (req, res) {
46-
let beaconObj = req.body;
46+
let beaconObj = req.body
4747
if (beaconObj) {
48-
util.showNotification(beaconObj);
49-
util.engageBeacon(beaconObj);
50-
util.playSound(beaconObj);
48+
util.showNotification(beaconObj)
49+
util.engageBeacon(beaconObj)
50+
util.playSound(beaconObj)
5151
}
5252

53-
res.send({control_status: config.get('allowControl')});
54-
});
53+
res.send({ control_status: config.get('allowControl') })
54+
})
5555

5656
server.use(function (req, res) {
57-
res.status(404).send({error: true, url: req.originalUrl + ' not found.'});
58-
});
59-
57+
res.status(404).send({ error: true, url: req.originalUrl + ' not found.' })
58+
})
59+
6060
io.sockets.on('connection', (socket) => {
61-
let ipAddr = socket.handshake.address;
62-
socket.emit('control_status', config.get('allowControl'));
61+
let ipAddr = socket.handshake.address
62+
socket.emit('control_status', config.get('allowControl'))
6363

64-
socket.on('version', function() {
65-
socket.emit('version', VERSION);
66-
});
64+
socket.on('version', function () {
65+
socket.emit('version', VERSION)
66+
})
6767

68-
socket.on('control_status', function() {
69-
socket.emit('control_status', config.get('allowControl'));
70-
});
68+
socket.on('control_status', function () {
69+
socket.emit('control_status', config.get('allowControl'))
70+
})
7171

72-
socket.on('devices', function() {
73-
socket.emit('devices', util.getDevices());
74-
});
72+
socket.on('devices', function () {
73+
socket.emit('devices', util.getDevices())
74+
})
7575

76-
socket.on('colors', function() {
77-
socket.emit('colors', util.getColors());
78-
});
76+
socket.on('colors', function () {
77+
socket.emit('colors', util.getColors())
78+
})
7979

80-
socket.on('sounds', function() {
81-
socket.emit('sounds', util.getSounds());
82-
});
80+
socket.on('sounds', function () {
81+
socket.emit('sounds', util.getSounds())
82+
})
8383

84-
socket.on('beacon', function(beaconObj) {
84+
socket.on('beacon', function (beaconObj) {
8585
if (beaconObj) {
86-
util.showNotification(beaconObj);
87-
util.engageBeacon(beaconObj);
88-
util.playSound(beaconObj);
86+
util.showNotification(beaconObj)
87+
util.engageBeacon(beaconObj)
88+
util.playSound(beaconObj)
8989
}
90-
});
91-
});
90+
})
91+
})
9292

93-
httpServer.listen(port);
94-
console.log('REST/Socket.io API server started on: ' + port);
93+
httpServer.listen(port)
94+
console.log('REST/Socket.io API server started on: ' + port)
9595

96-
util.startUp();
96+
util.startUp()
9797
}
9898

9999
static sendControlStatus() {
100-
io.sockets.emit('control_status', config.get('allowControl'));
100+
io.sockets.emit('control_status', config.get('allowControl'))
101101
}
102102
}
103103

104-
module.exports = API;
104+
module.exports = API

Diff for: api.md

+20-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33
beacon has both a REST-based API as well as a socket.io API. Both run on Port `8802`.
44

55
## REST API
6+
67
It is possible to disable remote control within the context menu of the beacon application. If this is done, you will receive this response when using the REST API:
8+
79
```javascript
8-
{ control_status: false }
10+
{
11+
control_status: false
12+
}
913
```
1014

1115
## socket.io API
@@ -15,30 +19,39 @@ Upon connection, the server will emit the `control_status` event to let the clie
1519
## Available Methods
1620

1721
### REST: `/version`: GET
22+
1823
### socket.io: 'version'
1924

2025
Returns the version of beacon currently running.
26+
2127
```javascript
2228
{version: 0.1.0}
2329
```
2430

2531
### REST: `/control_status`: GET
32+
2633
### socket.io: 'control_status'
2734

2835
Returns whether remote control is currently enabled or not in beacon
36+
2937
```javascript
30-
{control_status: true}
38+
{
39+
control_status: true
40+
}
3141
```
3242

3343
### REST: `/devices`: GET
44+
3445
### socket.io: 'devices'
3546

3647
Returns a list of devices/beacons available.
3748

3849
### REST: `/colors`: GET
50+
3951
### socket.io: 'colors'
4052

4153
Returns a list of available colors that beacon can use.
54+
4255
```javascript
4356
{ id: 'red', label: 'Red', r: 255, g: 0, b: 0 },
4457
{ id: 'green', label: 'Green', r: 0, g: 255, b: 0 },
@@ -51,19 +64,23 @@ Returns a list of available colors that beacon can use.
5164
```
5265

5366
### REST: `/sounds`: GET
67+
5468
### socket.io: 'sounds'
5569

5670
Returns a list of available sounds/tones that beacon can use.
71+
5772
```javascript
5873
{ id: 'single', label: '*' },
5974
{ id: 'triple', label: '* * *' },
6075
{ id: 'hey', label: 'Hey' },
6176
```
6277

6378
### REST: `/beacon`: POST
79+
6480
### socket.io: 'beacon'
6581

6682
Send a beacon object via `application/json` in a POST request to control beacon.
83+
6784
```javascript
6885
{
6986
device: `deviceId` or 'all',
@@ -80,4 +97,4 @@ Send a beacon object via `application/json` in a POST request to control beacon.
8097

8198
### socket.io: `error`:
8299

83-
Emitted whenever there is an error. Contains the error message as a string.
100+
Emitted whenever there is an error. Contains the error message as a string.

Diff for: config.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)