-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
31 lines (24 loc) · 864 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { createServer, createHttpServer } from "./server";
import { testDatabaseConnection } from "./database";
import OpenAI from "openai";
import { fetchAndCacheModelList } from "./clientSession";
console.log("Initializing question.sh server...");
const sshServer = createServer();
const httpServer = createHttpServer();
await testDatabaseConnection();
// Initialize OpenAI SDK with OpenRouter configuration
export const openai = new OpenAI({
baseURL: "https://openrouter.ai/api/v1",
apiKey: process.env.OPENROUTER_API_KEY,
defaultHeaders: {
"HTTP-Referer": "Question.sh", // Replace with your actual site URL
"X-Title": "Question.sh", // Replace with your app name
},
});
process.on("SIGINT", () => {
console.log("\nShutting down servers...");
sshServer.close();
httpServer.close();
process.exit(0);
});
fetchAndCacheModelList();