summaryrefslogtreecommitdiffstats
path: root/backend/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'backend/index.ts')
-rw-r--r--backend/index.ts36
1 files changed, 36 insertions, 0 deletions
diff --git a/backend/index.ts b/backend/index.ts
new file mode 100644
index 0000000..140e7b9
--- /dev/null
+++ b/backend/index.ts
@@ -0,0 +1,36 @@
+import express from "express";
+import cors from "cors";
+import * as dotenv from "dotenv";
+
+// import abc from "./modules/dummy";
+// abc();
+
+// const global = { stop: false };
+
+dotenv.config();
+const app = express();
+const PORT = 5000;
+
+
+app.use(express.json());
+app.use(cors());
+app.use("/", express.static("../dist"));
+
+const longpoll = require("express-longpoll")(app);
+longpoll.create("/poll", cors());
+var data = { text: "Some data" };
+
+app.post("/send", (req, res) => {
+ console.log(JSON.stringify(req));
+ longpoll.publish("/poll", req.body)
+ res.send("OK");
+});
+
+app.listen(PORT, () => {
+ console.log(`[server]: Server is running at https://localhost:${PORT}`);
+});
+// longpoll.publish("/poll", data);
+
+setInterval(function () {
+ longpoll.publish("/poll", data);
+}, 1000); \ No newline at end of file