11#!/usr/bin/env -S bun
2+ "use strict" ;
23const DXCluster = require ( './dxcluster' ) ;
34const express = require ( "express" ) ;
45const app = express ( )
@@ -35,6 +36,7 @@ app.get(config.baseUrl + '/spot/:qrg', function(req, res){ // Fallback Ro
3536 var qrg = req . params . qrg ;
3637 single_spot = get_singlespot ( qrg ) ;
3738 res . json ( single_spot ) ;
39+ single_spot = { } ;
3840} ) ;
3941
4042app . get ( config . baseUrl + '/spots' , function ( req , res ) { // Fallback Route
@@ -44,6 +46,7 @@ app.get(config.baseUrl + '/spots', function(req, res){ // Fallback Route
4446app . get ( config . baseUrl + '/spots/:band' , function ( req , res ) { // Fallback Route
4547 bandspots = get_bandspots ( req . params . band ) ;
4648 res . json ( bandspots ) ;
49+ bandspots = [ ] ;
4750} ) ;
4851
4952app . get ( config . baseUrl + '/stats' , function ( req , res ) { // Fallback Route
@@ -52,6 +55,7 @@ app.get(config.baseUrl + '/stats', function(req, res){ // Fallback Route
5255 stats . freshest = get_freshest ( spots ) ;
5356 stats . oldest = get_oldest ( spots ) ;
5457 res . json ( stats ) ;
58+ status = { } ;
5559} ) ;
5660
5761reconnect ( ) ;
@@ -86,7 +90,8 @@ conn.on('spot', async function x(spot) {
8690 console . log ( spot ) ;
8791 console . log ( e ) ;
8892
89- }
93+ }
94+
9095 // console.log(spot.spotted + " @ " + spot.when);
9196} )
9297
@@ -229,11 +234,12 @@ function qrg2band(Frequency) {
229234async function dxcc_lookup ( call ) {
230235 return new Promise ( async ( resolve , reject ) => {
231236 try {
232- payload = { } ;
237+ let payload = { } ;
233238 payload . key = config . dxcc_lookup_wavelog_key ;
234239 payload . callsign = call ;
235240 result = await postData ( config . dxcc_lookup_wavelog_url , payload ) ;
236- returner = { } ;
241+ payload = { } ;
242+ let returner = { } ;
237243 returner . cont = result . cont ;
238244 if ( result . dxcc ) {
239245 returner . entity = toUcWord ( result . dxcc ) ;
@@ -250,6 +256,7 @@ async function dxcc_lookup(call) {
250256 returner . lat = null ;
251257 returner . lng = null ;
252258 }
259+ result = { } ;
253260 resolve ( returner ) ;
254261 } catch ( e ) {
255262 console . log ( e ) ;
@@ -260,22 +267,22 @@ async function dxcc_lookup(call) {
260267
261268
262269async function postData ( url = "" , data = { } ) {
263- // Default options are marked with *
264- const response = await fetch ( url , {
265- method : "POST" , // *GET, POST, PUT, DELETE, etc.
266- mode : "cors" , // no-cors, *cors, same-origin
267- cache : "no-cache" , // *default, no-cache, reload, force-cache, only-if-cached
268- credentials : "same-origin" , // include, *same-origin, omit
269- headers : {
270- "Content-Type" : "application/json" ,
271- // 'Content-Type': 'application/x-www-form-urlencoded',
272- } ,
273- redirect : "follow" , // manual, *follow, error
274- referrerPolicy : "no-referrer" , // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
275- body : JSON . stringify ( data ) , // body data type must match "Content-Type" header
276- } ) ;
277- returner = await response . json ( ) ;
278- return returner ;
270+ // Default options are marked with *
271+ const response = await fetch ( url , {
272+ method : "POST" , // *GET, POST, PUT, DELETE, etc.
273+ mode : "cors" , // no-cors, *cors, same-origin
274+ cache : "no-cache" , // *default, no-cache, reload, force-cache, only-if-cached
275+ credentials : "same-origin" , // include, *same-origin, omit
276+ headers : {
277+ "Content-Type" : "application/json" ,
278+ // 'Content-Type': 'application/x-www-form-urlencoded',
279+ } ,
280+ redirect : "follow" , // manual, *follow, error
281+ referrerPolicy : "no-referrer" , // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
282+ body : JSON . stringify ( data ) , // body data type must match "Content-Type" header
283+ } ) ;
284+ returner = await response . json ( ) ;
285+ return returner ;
279286}
280287
281288function toUcWord ( string ) {
0 commit comments