Apply prettier to server.js
This commit is contained in:
parent
26968a8a00
commit
7dd98d9a10
@ -1,6 +1,6 @@
|
||||
const WebSocket = require('ws');
|
||||
const net = require('net');
|
||||
const fs = require('fs');
|
||||
const WebSocket = require("ws");
|
||||
const net = require("net");
|
||||
const fs = require("fs");
|
||||
|
||||
const client = new net.Socket();
|
||||
const wss = new WebSocket.Server({ host: "127.0.0.1", port: 4321 });
|
||||
@ -13,23 +13,30 @@ wss.broadcast = function(data) {
|
||||
});
|
||||
};
|
||||
|
||||
client.connect(
|
||||
14580, "rotate.aprs2.net",
|
||||
() => client.write("user KC1GDW pass -1 filter r/43.90/-72.15/75\r\n"));
|
||||
client.connect(14580, "rotate.aprs2.net", () =>
|
||||
client.write("user KC1GDW pass -1 filter r/43.90/-72.15/75\r\n")
|
||||
);
|
||||
|
||||
client.on('data', function(data) {
|
||||
let str = data.toString('utf8').replace(/^\s+|\s+$/g, "");
|
||||
client.on("data", function(data) {
|
||||
let str = data.toString("utf8").replace(/^\s+|\s+$/g, "");
|
||||
console.log(str);
|
||||
|
||||
// strip whitespace, then handle multiple APRS packets per TCP packet
|
||||
str.split("\r\n").forEach(packet => {
|
||||
if (!packet.startsWith('#')) { // ignore comments
|
||||
if (!packet.startsWith("#")) {
|
||||
// ignore comments
|
||||
let date = new Date();
|
||||
let datestamp = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
let datestamp =
|
||||
date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
|
||||
let data = [datestamp, packet];
|
||||
console.log(data);
|
||||
fs.appendFile("log" + datestamp + ".json", JSON.stringify(data) + ",\n",
|
||||
err => {if (err) throw err;});
|
||||
fs.appendFile(
|
||||
"log" + datestamp + ".json",
|
||||
JSON.stringify(data) + ",\n",
|
||||
err => {
|
||||
if (err) throw err;
|
||||
}
|
||||
);
|
||||
wss.broadcast(JSON.stringify(data));
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user