Advertisement
varun1729

Untitled

Apr 15th, 2023
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. const express = require("express");
  2. const bodyParser = require("body-parser");
  3.  
  4. const app = express();
  5. app.use(bodyParser.json());
  6.  
  7. app.post("/requestVote", (req, res) => {
  8. const { term, candidateId, lastLogIndex, lastLogTerm } = req.body;
  9.  
  10. const response = {
  11. term: "term",
  12. voteGranted: true,
  13. };
  14.  
  15. res.json(response);
  16. });
  17.  
  18. app.post("/appendEntries", (req, res) => {
  19. const { term, leaderId, prevLogIndex, prevLogTerm, entries, leaderCommit } =
  20. req.body;
  21.  
  22. const response = {
  23. term: term,
  24. success: true,
  25. };
  26.  
  27. res.json(response);
  28. });
  29.  
  30. app.post("/executeCommand", (req, res) => {
  31. const command = req.body;
  32.  
  33. const response = "OK";
  34.  
  35. res.send(response);
  36. });
  37.  
  38. app.listen(3000, () => {
  39. console.log("Server listening on port 3000");
  40. });
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement