-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgroups-server.ts
53 lines (45 loc) · 1.19 KB
/
groups-server.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
import { SkipServiceBroker } from "@skipruntime/helpers";
import express from "express";
const service = new SkipServiceBroker({
host: "localhost",
control_port: 8081,
streaming_port: 8080,
});
const app = express();
app.use(express.json());
app.get("/active_friends/:uid", (req, res) => {
service
.getStreamUUID("active_friends", Number(req.params.uid))
.then((uuid) => {
res.redirect(301, `http://localhost:8080/v1/streams/${uuid}`);
})
.catch((e: unknown) => {
res.status(500).json(e);
});
});
app.put("/users/:uid", (req, res) => {
service
.put("users", Number(req.params.uid), [req.body])
.then(() => {
res.status(200).json({});
})
.catch((e: unknown) => {
console.error("express error: ", e);
res.status(500).json(e);
});
});
app.put("/groups/:gid", (req, res) => {
service
.put("groups", Number(req.params.gid), [req.body])
.then(() => {
res.status(200).json({});
})
.catch((e: unknown) => {
console.error("express error: ", e);
res.status(500).json(e);
});
});
const port = 8082;
app.listen(port, () => {
console.log(`Groups REST wrapper listening at port ${port.toString()}`);
});