11import cron from "node-cron" ;
2+ import express from "express" ;
23import { dbConnect } from "./database" ;
3- import { sendFormReminders } from "./forms/formService" ;
4+ // import { sendFormReminders } from "./forms/formService";
45import slackbot from "./slackbot" ;
56import { logWithTime } from "./utils/timeUtils" ;
7+ import { registerApiRoutes } from "./api/routes" ;
68import {
79 createNewCoffeeChatRounds ,
810 reportStats ,
@@ -15,10 +17,10 @@ import { registerWelcomeHandler } from "./coffeeChats/coffeeChatWelcome";
1517export const SEMESTER = "sp24" ;
1618export const DEFAULT_PAIRING_FREQUENCY_DAYS = 14 ; // Default to every 2 weeks
1719
18- const initializeFormServices = async ( ) => {
19- await sendFormReminders ( ) ;
20- setInterval ( sendFormReminders , 1000 * 60 * 60 * 24 ) ; // Run every 24 hours
21- } ;
20+ // const initializeFormServices = async () => {
21+ // await sendFormReminders();
22+ // setInterval(sendFormReminders, 1000 * 60 * 60 * 24); // Run every 24 hours
23+ // };
2224
2325const initializeCoffeeChatServices = async ( ) => {
2426 // Register coffee chat actions and commands
@@ -57,10 +59,18 @@ const initializeCoffeeChatServices = async () => {
5759 logWithTime ( "✅ Midway reminders scheduled to run daily at 4pm" ) ;
5860} ;
5961
62+ // Set up custom API endpoints
63+ const apiServer = express ( ) ;
64+ registerApiRoutes ( apiServer ) ;
65+
6066export const startServer = async ( ) => {
6167 await dbConnect ( ) ;
6268 logWithTime ( "✅ Connected to MongoDB" ) ;
63- await slackbot . start ( process . env . PORT || 3000 ) ;
69+ await slackbot . start ( ) ;
70+ const port = Number ( process . env . PORT ) || 3000 ;
71+ apiServer . listen ( port , ( ) => {
72+ logWithTime ( `✅ API Server listening on port ${ port } ` ) ;
73+ } ) ;
6474 logWithTime ( "✅ Slackbot up and running!" ) ;
6575
6676 // Currently unused, so commenting out to avoid unnecessary API calls and logs. Can re-enable when form services are needed.
0 commit comments