recycleactor commited on
Commit
2b4ec23
·
verified ·
1 Parent(s): 4701327

Upload server.js

Browse files
Files changed (1) hide show
  1. server.js +11 -0
server.js CHANGED
@@ -469,6 +469,17 @@ function handleHls(req, res) {
469
 
470
  const server = http.createServer(async (req, res) => {
471
  const { pathname, query } = parseQuery(req.url);
 
 
 
 
 
 
 
 
 
 
 
472
 
473
  if (req.method === 'OPTIONS') {
474
  res.writeHead(204, { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', 'Access-Control-Allow-Headers': '*' });
 
469
 
470
  const server = http.createServer(async (req, res) => {
471
  const { pathname, query } = parseQuery(req.url);
472
+ const startedAt = Date.now();
473
+ const shouldLog = pathname === '/health' || pathname.startsWith('/uakinogo/') || pathname.startsWith('/alloha/') || pathname.startsWith('/turbo/');
474
+ if (shouldLog) {
475
+ try {
476
+ const q = (pathname === '/uakinogo/search' && query.q) ? (' q=' + String(query.q).slice(0, 120)) : '';
477
+ console.log('[req]', req.method, pathname + q);
478
+ } catch (e) {}
479
+ res.on('finish', () => {
480
+ try { console.log('[res]', req.method, pathname, res.statusCode, (Date.now() - startedAt) + 'ms'); } catch (e) {}
481
+ });
482
+ }
483
 
484
  if (req.method === 'OPTIONS') {
485
  res.writeHead(204, { 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS', 'Access-Control-Allow-Headers': '*' });