@@ -402,19 +402,27 @@ app.get("/trigger-poll", async (req, res) => {
402402} ) ;
403403
404404// ── Start ───────────────────────────────────────────────────────────────────
405- app . listen ( PORT , ( ) => {
406- console . log ( `
407- ┌──────────────────────────────────────────┐
408- │ GitHub Activity Tracker │
409- ├──────────────────────────────────────────┤
410- │ Watching: ${ GITHUB_USERNAME . padEnd ( 28 ) } │
411- │ Notify: ${ NOTIFY_EMAIL . padEnd ( 28 ) } │
412- │ Interval: ${ ( Number ( POLL_INTERVAL_MS ) / 1000 + "s" ) . padEnd ( 28 ) } │
413- │ Server: http://localhost:${ PORT . toString ( ) . padEnd ( 24 ) } │
414- └──────────────────────────────────────────┘
415- ` ) ;
405+ if ( require . main === module ) {
406+ app . listen ( PORT , ( ) => {
407+ console . log ( "=========================================" ) ;
408+ console . log ( `Server started successfully on port ${ PORT } ` ) ;
409+ console . log ( "=========================================" ) ;
410+ console . log ( `
411+ ┌──────────────────────────────────────────┐
412+ │ GitHub Activity Tracker │
413+ ├──────────────────────────────────────────┤
414+ │ Watching: ${ GITHUB_USERNAME . padEnd ( 28 ) } │
415+ │ Notify: ${ NOTIFY_EMAIL . padEnd ( 28 ) } │
416+ │ Interval: ${ ( Number ( POLL_INTERVAL_MS ) / 1000 + "s" ) . padEnd ( 28 ) } │
417+ │ Server: http://localhost:${ PORT . toString ( ) . padEnd ( 24 ) } │
418+ └──────────────────────────────────────────┘
419+ ` ) ;
420+
421+ // Run immediately, then on interval
422+ poll ( ) ;
423+ setInterval ( poll , Number ( POLL_INTERVAL_MS ) ) ;
424+ } ) ;
425+ }
416426
417- // Run immediately, then on interval
418- poll ( ) ;
419- setInterval ( poll , Number ( POLL_INTERVAL_MS ) ) ;
420- } ) ;
427+ // Export the app for Vercel / serverless deployments
428+ module . exports = app ;
0 commit comments