fix: dynamic uptime on footer causing spam in console

This commit is contained in:
2025-06-11 17:02:55 -07:00
parent 7065aeba69
commit 82ac23c63c

View File

@@ -1296,7 +1296,7 @@ async function serveM3UPlaylist( req, res )
return; return;
} }
const cachedUrl = getCache( decodedUrl, req ); const cachedUrl = getCache( req, decodedUrl );
if ( cachedUrl ) if ( cachedUrl )
{ {
const rewrittenPlaylist = await rewriteM3U( cachedUrl, req ); const rewrittenPlaylist = await rewriteM3U( cachedUrl, req );
@@ -1369,7 +1369,7 @@ async function serveM3UPlaylist( req, res )
return; return;
} }
setCache( decodedUrl, tokenizedUrl, 4 * 60 * 60 * 1000, req ); setCache( req, decodedUrl, tokenizedUrl, 4 * 60 * 60 * 1000 );
const hdUrl = tokenizedUrl.replace( 'tracks-v2a1', 'tracks-v1a1' ); const hdUrl = tokenizedUrl.replace( 'tracks-v2a1', 'tracks-v1a1' );
const rewrittenPlaylist = await rewriteM3U( hdUrl, req ); const rewrittenPlaylist = await rewriteM3U( hdUrl, req );
@@ -1441,10 +1441,14 @@ async function serveHealthCheck( req, res )
try try
{ {
const paramUrl = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'api' ); const paramUrl = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'api' );
const paramQuery = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'query' );
if ( !paramUrl ) if ( !paramUrl )
{ {
Log.debug( `/api`, chalk.yellow( `[health]` ), chalk.white( `⚙️` ), if ( paramQuery !== 'uptime' )
chalk.blueBright( `<msg>` ), chalk.gray( `No API key passed to health check` ) ); {
Log.debug( `/api`, chalk.yellow( `[health]` ), chalk.white( `⚙️` ),
chalk.blueBright( `<msg>` ), chalk.gray( `No API key passed to health check` ) );
}
} }
const statusCheck = const statusCheck =
@@ -1467,8 +1471,7 @@ async function serveHealthCheck( req, res )
'Content-Type': 'application/json' 'Content-Type': 'application/json'
}); });
const paramQuery = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'query' ); if ( paramQuery !== 'uptime' )
if ( paramQuery !== 'query' )
{ {
Log.ok( `/api`, chalk.yellow( `[health]` ), chalk.white( `` ), Log.ok( `/api`, chalk.yellow( `[health]` ), chalk.white( `` ),
chalk.greenBright( `<msg>` ), chalk.gray( `Response` ), chalk.greenBright( `<msg>` ), chalk.gray( `Response` ),
@@ -1789,7 +1792,7 @@ async function serveGZP( res, req )
cache > set cache > set
*/ */
function setCache( key, value, ttl, req ) function setCache( req, key, value, ttl )
{ {
const expiry = Date.now() + ttl; const expiry = Date.now() + ttl;
cache.set( key, { cache.set( key, {
@@ -1809,7 +1812,7 @@ function setCache( key, value, ttl, req )
cache > get cache > get
*/ */
function getCache( key, req ) function getCache( req, key )
{ {
const cached = cache.get( key ); const cached = cache.get( key );
if ( cached && cached.expiry > Date.now() ) if ( cached && cached.expiry > Date.now() )
@@ -2021,13 +2024,17 @@ const server = http.createServer( ( req, resp ) =>
loadFile channel?url=https%3A%2F%2Ftvpass.org%2Fchannel%2Fabc-wabc-new-york-ny%2F loadFile channel?url=https%3A%2F%2Ftvpass.org%2Fchannel%2Fabc-wabc-new-york-ny%2F
*/ */
Log.debug( `http`, chalk.yellow( `[requests]` ), chalk.white( `⚙️` ), const paramQuery = new URL( req.url, `http://${ req.headers.host }` ).searchParams.get( 'query' );
chalk.blueBright( `<msg>` ), chalk.gray( `Request started` ), if ( paramQuery !== 'uptime' )
chalk.blueBright( `<client>` ), chalk.gray( `${ clientIp( req ) }` ), {
chalk.blueBright( `<request.url>` ), chalk.gray( `${ req.url }` ), Log.debug( `http`, chalk.yellow( `[requests]` ), chalk.white( `⚙️` ),
chalk.blueBright( `<reqUrl>` ), chalk.gray( `${ reqUrl }` ), chalk.blueBright( `<msg>` ), chalk.gray( `Request started` ),
chalk.blueBright( `<file>` ), chalk.gray( `${ loadFile }` ), chalk.blueBright( `<client>` ), chalk.gray( `${ clientIp( req ) }` ),
chalk.blueBright( `<method>` ), chalk.gray( `${ method }` ) ); chalk.blueBright( `<request.url>` ), chalk.gray( `${ req.url }` ),
chalk.blueBright( `<reqUrl>` ), chalk.gray( `${ reqUrl }` ),
chalk.blueBright( `<file>` ), chalk.gray( `${ loadFile }` ),
chalk.blueBright( `<method>` ), chalk.gray( `${ method }` ) );
}
if ( subdomainRestart.some( ( urlKeyword ) => loadFile.startsWith( urlKeyword ) ) ) if ( subdomainRestart.some( ( urlKeyword ) => loadFile.startsWith( urlKeyword ) ) )
{ {