Skip to content

Commit

Permalink
Expose transactions per minute via mocked server endpoint (#174)
Browse files Browse the repository at this point in the history
  • Loading branch information
kohrapha authored Dec 4, 2020
1 parent 27f1cb6 commit a1d74b5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions mocked_server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,25 @@ const http = require('http');
const fs = require('fs');
const app = express();

var get_data = ""
let data = "";
let numTransactions = 0;
const startTime = new Date();

app.get("/check-data", function(req, res){
res.send(get_data);
// Retrieve number of transactions per minute
app.get("/tpm", function (req, res) {
// Calculate duration in minutes
const duration = Math.ceil((new Date() - startTime) / 60000);
const tpm = numTransactions / duration;
res.send({ tpm });
});

app.get("/check-data", function (req, res) {
res.send(data);
});

app.all('/put-data*', function (req, res) {
get_data = "success";
data = "success";
numTransactions++;
res.send('{}');
});

Expand Down

0 comments on commit a1d74b5

Please sign in to comment.