-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
32 lines (26 loc) · 818 Bytes
/
server.js
File metadata and controls
32 lines (26 loc) · 818 Bytes
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
32
// npm packages
import express from "express";
import mongoose from "mongoose";
import TelegramBot from "node-telegram-bot-api";
// export const
import { keys } from "./src/lib/keys.js";
import { botText } from "./src/controllers/botOn.js";
import { botPhotos } from "./src/controllers/botPhotos.js";
import { botOn } from "./src/controllers/botMessage.js";
// destructuring
const { port, mongo_connection, telegram_token } = keys;
// variables
const app = express();
const bot = new TelegramBot(telegram_token, { polling: true });
app.use(express.json());
// helper functions
botText(bot);
botOn(bot);
botPhotos(bot);
// connection to mongodb
mongoose
.connect(mongo_connection)
.then(() => {
app.listen(port, () => console.log(`Server listening on port ${port}`));
})
.catch((err) => err.message);