Skip to content

Instantly share code, notes, and snippets.

@mcgill-a
Created September 25, 2023 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcgill-a/c9f01e36196a983019c151b33c859ad1 to your computer and use it in GitHub Desktop.
Save mcgill-a/c9f01e36196a983019c151b33c859ad1 to your computer and use it in GitHub Desktop.
A minimal backend controller
userService.change.subscribe((change) =>
io.sockets.emit(SocketChannel.user, JSON.stringify(change))
);
app.post("/users/join", (req, res) => {
try {
res.json(userService.join(<User>req.body));
} catch (error) {
res.status(400).send(error);
}
console.log("join", req.body);
});
app.post("/users/leave", (req, res) => {
try {
res.json(userService.leave(<User>req.body));
} catch (error) {
res.status(400).send(error);
}
console.log("leave", req.body);
});
app.post("/users/position", (req, res) => {
try {
res.json(userService.position(<User>req.body));
} catch (error) {
res.status(400).send(error);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment