File size: 816 Bytes
56ddde0
 
bb4fd67
3a2fb4a
3fa6943
aa680e5
 
 
 
3a2fb4a
 
 
aa680e5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e69b6a1
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
// startup like fastapi similar

import { Database } from '../database/database.js';
import { InitBot } from '../bot/telegrambot.js';
import { IsTelegramBot } from '../config.js';
const port = 7860

const startup = async () => {
    try {
        if (IsTelegramBot) {
          await InitBot();
        }
        const dbClient = new Database("AkenoXJs", "FastJsAPI");
        console.log("Starting application...");
        await dbClient.connect();
        console.log("MongoDB connected successfully.");
    } catch (error) {
        console.error("Error during startup:", error.message);
        process.exit(1);
    }
};

const startServer = async (app) => {
    await startup();
    app.listen(port, () => {
        console.log(`Server running on http://localhost:${port}`);
    });
};

export { startServer };