Skip to content

Commit 0d6b2bb

Browse files
committed
feat: relocate bot launch logic from server.js to app.js
1 parent 8abef70 commit 0d6b2bb

2 files changed

Lines changed: 5 additions & 6 deletions

File tree

server.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@ import app from "./src/app.js";
22
import { PORT } from "./src/config/config.js";
33

44
import { connectDB } from "./src/config/db.js";
5-
import { bot } from "./src/services/telegraf.js";
65

76
const startServer = () => {
87
app.listen(PORT, () => {
98
console.log(`Server is running on port ${PORT}`);
109
connectDB();
1110

12-
bot
13-
.launch()
14-
.then(() => console.log("Bot started successfully"))
15-
.catch((err) => console.error("Bot launch failed:", err));
16-
1711
// startCronJob();
1812
});
1913
};

src/app.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ app.get("/", (req, res) => {
1111
app.use(cors());
1212
app.use(express.json());
1313

14+
bot
15+
.launch()
16+
.then(() => console.log("Bot started successfully"))
17+
.catch((err) => console.error("Bot launch failed:", err));
18+
1419
process.once("SIGINT", () => bot.stop("SIGINT"));
1520
process.once("SIGTERM", () => bot.stop("SIGTERM"));
1621

0 commit comments

Comments
 (0)