Charlie commited on
Commit
de3f96c
·
1 Parent(s): 59ff286
Files changed (1) hide show
  1. server.ts +16 -12
server.ts CHANGED
@@ -3,25 +3,29 @@ import * as express from "express";
3
  const PORT = 7860;
4
 
5
  if (!process.env.WEBHOOK_SECRET || !process.env.HF_TOKEN) {
6
- console.error(
7
- "This app needs those env variables to be defined",
8
- "WEBHOOK_SECRET, HF_TOKEN"
9
- );
10
- process.exit();
11
  }
12
 
13
  const app = express();
14
  app.use(express.json());
15
 
 
 
 
 
16
  app.post("/", async (req, res) => {
17
- if (req.header("X-Webhook-Secret") !== process.env.WEBHOOK_SECRET) {
18
- console.error("incorrect secret");
19
- return res.status(400).json({ error: "incorrect secret" });
20
- }
21
- console.log(req.body);
22
- res.json({ success: true });
23
  });
24
 
25
  app.listen(PORT, () => {
26
- console.debug(`server started at http://localhost:${PORT}`);
27
  });
 
3
  const PORT = 7860;
4
 
5
  if (!process.env.WEBHOOK_SECRET || !process.env.HF_TOKEN) {
6
+ console.error(
7
+ "This app needs those env variables to be defined",
8
+ "WEBHOOK_SECRET, HF_TOKEN"
9
+ );
10
+ process.exit();
11
  }
12
 
13
  const app = express();
14
  app.use(express.json());
15
 
16
+ app.get("/", (req, res) => {
17
+ res.json({ hello: "world" });
18
+ });
19
+
20
  app.post("/", async (req, res) => {
21
+ if (req.header("X-Webhook-Secret") !== process.env.WEBHOOK_SECRET) {
22
+ console.error("incorrect secret");
23
+ return res.status(400).json({ error: "incorrect secret" });
24
+ }
25
+ console.log(req.body);
26
+ res.json({ success: true });
27
  });
28
 
29
  app.listen(PORT, () => {
30
+ console.debug(`server started at http://localhost:${PORT}`);
31
  });