Created
September 25, 2023 09:31
-
-
Save mcgill-a/c9f01e36196a983019c151b33c859ad1 to your computer and use it in GitHub Desktop.
A minimal backend controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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