|
|
import express, { Request } from "express"; |
|
|
import cors from "cors"; |
|
|
import 'dotenv/config' |
|
|
import { setupRoutes } from "./routes"; |
|
|
import { PORT } from "./config"; |
|
|
|
|
|
import { loginWithSession } from "./controllers"; |
|
|
import { handleCreateTask, handleLoginWithSession, setupTaskSystem } from "./services"; |
|
|
import { fetchDataFromTable, updateDataInTable } from "./db/supabaseHelper"; |
|
|
import { normalizeArabicText } from "./utils"; |
|
|
import { handleAddTelegrafBot } from "./bots"; |
|
|
async function startServer() { |
|
|
const app = express(); |
|
|
app.use(express.json()); |
|
|
app.use( |
|
|
cors({ |
|
|
origin: "*", |
|
|
methods: ["GET", "POST", "PUT", "DELETE"], |
|
|
allowedHeaders: ["Content-Type", "Authorization"], |
|
|
}) |
|
|
); |
|
|
|
|
|
setupRoutes(app); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.listen(PORT, () => { |
|
|
console.log(`Server running on port ${PORT}`); |
|
|
}); |
|
|
} |
|
|
|
|
|
startServer(); |
|
|
|
|
|
|
|
|
|