-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (28 loc) · 904 Bytes
/
index.js
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
const express = require("express")
require("dotenv").config()
const { handler } = require("./controller")
const path = require("path")
const u = require("util")
const fs = require("fs")
const app = express()
const PORT = 5012;
app.use(express.json())
app.get("/", async (req, res) => {
// this is only for website to show side is working
res.send("you telegram bot is working.....")
})
app.post("/", async (req, res) => {
// all the things handle by this function
await handler(req, "post")
// if every thing is ok send 200 status code
res.sendStatus(200);
})
// get file name from path
app.get("/images/:filename", async (req, res) => {
let filePath = path.join(__dirname,"/images",req.params.filename)
res.sendFile(filePath)
})
app.listen(PORT, (err) => {
if (err) return console.log(err)
console.log(`App Running at Port http://localhost:${5012}`)
})