ATlast — you'll never need to find your favorites on another platform again. Find your favs in the ATmosphere.
atproto
16
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: add results and test stuff for server

byarielm.fyi d4eaef6e 2c3aee7b

verified
+22 -15
+22 -15
packages/api/src/server.ts
··· 7 7 import { errorHandler } from "./middleware/error"; 8 8 import authRoutes from "./routes/auth"; 9 9 import searchRoutes from "./routes/search"; 10 + import resultsRoutes from "./routes/results"; 10 11 import { db } from "./db/client"; 11 12 import { sql } from "kysely"; 12 13 ··· 51 52 // Mount routes 52 53 app.route("/api/auth", authRoutes); 53 54 app.route("/api/search", searchRoutes); 55 + app.route("/api/results", resultsRoutes); 54 56 55 57 // Health check endpoint (Phase 3C - with database check) 56 58 app.get("/api/health", async (c) => { ··· 85 87 // Error handling 86 88 app.onError(errorHandler); 87 89 88 - // Start server 89 - const port = parseInt(process.env.PORT || "3000"); 90 + // Start server only when run directly (not imported for tests) 91 + const isMainModule = import.meta.url === `file://${process.argv[1]?.replace(/\\/g, '/')}`; 92 + const isTestEnv = process.env.NODE_ENV === 'test' || process.env.VITEST; 93 + 94 + if (isMainModule && !isTestEnv) { 95 + const port = parseInt(process.env.PORT || "3000"); 90 96 91 - console.log(`🚀 ATlast API server starting...`); 92 - console.log(`📍 Port: ${port}`); 93 - console.log(`🌍 Environment: ${process.env.NODE_ENV || "development"}`); 94 - console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`); 97 + console.log(`🚀 ATlast API server starting...`); 98 + console.log(`📍 Port: ${port}`); 99 + console.log(`🌍 Environment: ${process.env.NODE_ENV || "development"}`); 100 + console.log(`━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━`); 95 101 96 - serve( 97 - { 98 - fetch: app.fetch, 99 - port, 100 - }, 101 - (info) => { 102 - console.log(`✅ Server is running on http://localhost:${info.port}`); 103 - }, 104 - ); 102 + serve( 103 + { 104 + fetch: app.fetch, 105 + port, 106 + }, 107 + (info) => { 108 + console.log(`✅ Server is running on http://localhost:${info.port}`); 109 + }, 110 + ); 111 + } 105 112 106 113 export default app;