@@ -19,7 +19,7 @@ import {
1919 getVTReleaseStats ,
2020 getVTStats ,
2121 GHCRApi ,
22- incrBadge ,
22+ incrKey ,
2323 sendInflux ,
2424} from './api.js'
2525
@@ -291,9 +291,9 @@ app.get('/uptime', async (req, res) => {
291291 getBadge ( message , req . query , { label : 'uptime' , lucide : 'clock-arrow-up' } , res )
292292} )
293293
294- // Handler 404
294+ // Handler - 404
295295app . use ( ( req , res ) => {
296- debug ( '404:' , req . originalUrl )
296+ debug ( '404 - originalUrl :' , req . originalUrl )
297297 const data = {
298298 message : '404 - URL Not Found' ,
299299 color : 'red' ,
@@ -303,25 +303,28 @@ app.use((req, res) => {
303303 // noinspection JSCheckFunctionSignatures
304304 const badge = makeBadge ( data )
305305 sendBadge ( res , badge , 404 )
306+ incrKey ( 'badges_404' ) . catch ( console . error )
306307} )
307308
309+ // Handler - Error
308310app . use ( errorHandler )
309311
310- // NOTE: Must determine which errors to pass to sentry.
311- // Defining it after the error handler only catches errors in the handler...
312+ // Handler - Sentry Error - NOTE: This only catches errorHandler errors currently...
312313if ( Sentry ) Sentry . setupExpressErrorHandler ( app )
313314
314315function errorHandler ( err , req , res ) {
315316 // console.log('errorHandler:', err)
316- debug ( 'errorHandler:' , err . message )
317+ debug ( 'errorHandler - originalUrl:' , req . originalUrl )
318+ debug ( 'err.message:' , err . message )
317319 const data = {
318320 message : err . message || 'Unknown Error' ,
319321 color : 'red' ,
320322 style : req . query . style || 'flat' ,
321323 }
322324 debug ( 'data:' , data )
323325 const badge = makeBadge ( data )
324- if ( res ) sendBadge ( res , badge )
326+ sendBadge ( res , badge )
327+ incrKey ( 'badges_error' ) . catch ( console . error )
325328}
326329
327330/**
@@ -370,7 +373,7 @@ function getBadge(message, query = {}, options = {}, res = null) {
370373 // debug('data:', data)
371374 const badge = makeBadge ( data )
372375 if ( res ) sendBadge ( res , badge )
373- incrBadge ( ) . catch ( console . error )
376+ incrKey ( 'badges_total' ) . catch ( console . error )
374377 return badge
375378}
376379
0 commit comments