2026-03-18 21:20:51 -04:00
|
|
|
import { createServer } from "http";
|
|
|
|
|
import app from "./app.js";
|
|
|
|
|
import { attachWebSocketServer } from "./routes/events.js";
|
2026-03-18 21:01:13 -04:00
|
|
|
import { rootLogger } from "./lib/logger.js";
|
2026-03-19 19:27:13 +00:00
|
|
|
import { timmyIdentityService } from "./lib/timmy-identity.js";
|
|
|
|
|
import { startEngagementEngine } from "./lib/engagement.js";
|
2026-03-13 23:21:55 +00:00
|
|
|
|
|
|
|
|
const rawPort = process.env["PORT"];
|
|
|
|
|
|
|
|
|
|
if (!rawPort) {
|
2026-03-18 21:20:51 -04:00
|
|
|
throw new Error("PORT environment variable is required but was not provided.");
|
2026-03-13 23:21:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const port = Number(rawPort);
|
|
|
|
|
|
|
|
|
|
if (Number.isNaN(port) || port <= 0) {
|
|
|
|
|
throw new Error(`Invalid PORT value: "${rawPort}"`);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-18 21:20:51 -04:00
|
|
|
const server = createServer(app);
|
|
|
|
|
attachWebSocketServer(server);
|
|
|
|
|
|
|
|
|
|
server.listen(port, () => {
|
2026-03-18 21:01:13 -04:00
|
|
|
rootLogger.info("server started", { port });
|
2026-03-19 19:27:13 +00:00
|
|
|
rootLogger.info("timmy identity", { npub: timmyIdentityService.npub });
|
2026-03-18 21:02:06 +00:00
|
|
|
const domain = process.env["REPLIT_DEV_DOMAIN"];
|
|
|
|
|
if (domain) {
|
2026-03-18 21:01:13 -04:00
|
|
|
rootLogger.info("public url", { url: `https://${domain}/api/ui` });
|
2026-03-18 21:20:51 -04:00
|
|
|
rootLogger.info("tower url", { url: `https://${domain}/tower` });
|
|
|
|
|
rootLogger.info("ws url", { url: `wss://${domain}/api/ws` });
|
2026-03-18 21:02:06 +00:00
|
|
|
}
|
2026-03-19 19:27:13 +00:00
|
|
|
startEngagementEngine();
|
2026-03-13 23:21:55 +00:00
|
|
|
});
|