diff --git a/app.js b/app.js index 95527e4..5fab825 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ import axios from "axios"; -import express, { json, query } from "express"; +import express, { json } from "express"; import Queue from "bull"; import Bottleneck from "bottleneck"; @@ -8,9 +8,9 @@ app.use(json()); const requestQueue = new Queue("request-queue", { redis: { - host: '127.0.0.1', - port: 6379 - } + host: "127.0.0.1", + port: 6379, + }, }); const limiter = new Bottleneck({ @@ -41,8 +41,7 @@ async function sendRequest(data) { requestQueue.process(async (job) => { try { - const result = await limiter.schedule(() => sendRequest(job.data)); - return result; + await limiter.schedule(() => sendRequest(job.data)); } catch (error) { throw new Error(`Request failed: ${error.message}`); } @@ -89,7 +88,6 @@ app.get("/bot:token/*", async (req, res) => { }); app.post("/bot:token/*", async (req, res) => { - const url = req.url; const botTokenEndIndex = url.indexOf("/", 1); const botToken = url.substring(4, botTokenEndIndex); @@ -112,7 +110,6 @@ app.post("/bot:token/*", async (req, res) => { } }); - app.listen(3000, () => { console.log("Microservice listening on port 3000"); }); diff --git a/package.json b/package.json index c5d236c..fb4f93f 100644 --- a/package.json +++ b/package.json @@ -15,4 +15,4 @@ "express": "^4.19.2" }, "type": "module" -} +} \ No newline at end of file