-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
35 lines (26 loc) · 945 Bytes
/
index.ts
File metadata and controls
35 lines (26 loc) · 945 Bytes
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
import "dotenv/config";
import express from "express";
import { createWebhookRouter } from "./webhook";
import { redisStorage } from "./redis";
import { assertNonNullish } from "./util";
process.on("unhandledRejection", (reason) => {
console.error("Unhandled rejection:", reason);
});
const app = express();
assertNonNullish(process.env.UPSTASH_REDIS_REST_URL, "UPSTASH_REDIS_REST_URL is not set");
assertNonNullish(process.env.UPSTASH_REDIS_REST_TOKEN, "UPSTASH_REDIS_REST_TOKEN is not set");
redisStorage.register({
url: process.env.UPSTASH_REDIS_REST_URL,
token: process.env.UPSTASH_REDIS_REST_TOKEN,
retry: 3,
});
/** 요청 JSON 바디 파싱 */
app.use(express.json());
app.use("/api", createWebhookRouter());
app.get("/health", (_req, res) => {
res.status(200).json({ status: "ok" });
});
const port = Number(process.env.PORT) || 3000;
app.listen(port, () => {
console.log(`mumu server running on port:${port}`);
});