-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
46 lines (36 loc) · 1.86 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import express from "express";
import passport from "passport";
import { connectDB } from "./src/mongo/db";
import setupTelegramRoutes from "./src/routes/telegram.router";
import imagesRoutes from "./src/routes/images.router";
import cors from "cors";
import path from "path";
import { TelegramService } from "./src/services/botServices/telegram.service";
import { Telegraf } from "telegraf";
import dotenv from "dotenv";
const imagesDirectory = path.join(__dirname, `./static_files/photos/`);
const imagesDoorDirectory = path.join(__dirname, `./static_files/door_photos/`);
dotenv.config({
path: path.resolve(__dirname, `.env.${process.env.NODE_ENV}`),
});
const app = express();
app.use(cors());
app.use(express.static(path.join(process.cwd(), "./client_react/build")));
console.log(path.join(process.cwd(), "./client_react/build"))
app.use(express.json());
app.use(passport.initialize());
app.use("/images", express.static(imagesDirectory));
app.use("/images_door", express.static(imagesDoorDirectory));
app.use("/api/images", imagesRoutes);
const bot = new Telegraf(process.env.TELEGRAM_TOKEN!);
bot.launch();
const telegramService = new TelegramService(bot);
app.use("/api/telegram", setupTelegramRoutes(telegramService));
async function init() {
await connectDB();
app.listen(process.env.PORT || 3000, () => {
console.log("Listening on port", process.env.PORT || 3000);
});
}
init();
// TODO 1) Сконфигурировать adminjs 2) Насроить докерфайл и скрипт для запуска контейнера в package.json 3) Рефакторинг фронта (добавить роутер в главный компонент, разбить основной компонент на несколько, добавить компоненты с авторизацией и регистрацией, исправить файл со стилями)