-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.ts
85 lines (70 loc) · 2.02 KB
/
app.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Purpose: Main entry point for the application.
// Import the configuration.
import {
httpConfig,
} from "./src/config";
// Import the application.
import {
app,
indexHandler,
heartHandler,
staticHandler,
checkHeartCode,
} from "./src/server";
// Import listen providers.
import MatrixListen from "./src/providers/matrix/listen";
import DiscordListen from "./src/providers/discord/listen";
import TelegramListen from "./src/providers/telegram/listen";
// Import hook providers.
import LINEHook from "./src/providers/line/hook";
// Import send providers.
import LINESend from "./src/providers/line/send";
import MatrixSend from "./src/providers/matrix/send";
import DiscordSend from "./src/providers/discord/send";
import TelegramSend from "./src/providers/telegram/send";
import OpenaiSend from "./src/providers/openai/send";
import {
hookRouter,
registerSendProviders,
registerHookProviders,
registerListenProviders,
} from "./src/registry";
// Register all senders.
await registerSendProviders([
new LINESend(),
new MatrixSend(),
new DiscordSend(),
new TelegramSend(),
new OpenaiSend(),
]);
// Register all listeners.
await registerListenProviders([
new MatrixListen(),
new DiscordListen(),
new TelegramListen(),
]);
// Register all Hookers.
await registerHookProviders([
new LINEHook(),
]);
// This route is used to handle the index.
app.get("/", indexHandler);
// This route is used to serve static files.
app.use("/static", staticHandler);
// This route is used to handle the heart.
app.get("/heart", heartHandler);
// This route is used to handle the hooks.
app.use("/hooks", hookRouter);
// Define the port to expose the application on.
const {
bindHost,
bindPort,
} = httpConfig();
// Create a server and listen to it.
app.listen(bindPort, bindHost, () => {
console.info("Arona");
console.info("===");
console.info("A simple bridge for every messenger.");
console.info(`Listening on http://${bindHost}:${bindPort}`);
checkHeartCode();
});