-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
43 lines (33 loc) · 1.02 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
import startAnalyzer from "./bot";
import express from "express";
import Timer = NodeJS.Timer;
import * as WebSocket from "ws";
import { Router, Request, Response } from "express";
import { AddressInfo, WebSocketServer } from "ws";
import * as http from "http";
import { BotStorage } from "./chatScore";
import axios from "axios";
import cors = require("cors");
startAnalyzer();
const app = express();
app.use(cors());
// initialize a simple http server
const server = http.createServer(app);
app.get("/image", (req, res) => {
res.send(BotStorage.getInstance().latestImageURL);
});
app.get("/question", (req, res) => {
res.send(BotStorage.getInstance().latestQuestion);
});
app.get("/background", (req, res) => {
res.send(BotStorage.getInstance().overlayBackground);
});
app.get("/message", (req, res) => {
res.send(BotStorage.getInstance().latestMessage);
});
app.get("/tasks", (req, res) => {
res.send(BotStorage.getInstance().tasks);
});
app.listen(8000, () => {
console.log(`Example app listening on port 8000`);
});