0

I'd like to build a NodeJS server that responds to requests just one at the time.

Basically: by doing fetch('<domain>/request/<id> I want that untill the client received the data the other requests are queued. Is it possible?

1 Answers1

0

An npm module like express-queue could work.

var express = require('express');
var queue = require('express-queue');
var app = express();
app.use(queue({
    activeLimit: 1
}));

app.use("*", function(req, res, next) {
    setTimeout(function() {
        res.send("OK");
    }, 2000);
});
app.listen(3000);
Brahma Dev
  • 1,955
  • 1
  • 12
  • 18