Created
July 4, 2017 17:51
-
-
Save adsurbum/b3169fb002af6dd66e9fc9ec5b98aafb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* 1 req per 30 ms. | |
*/ | |
const express = require('express') | |
const app = express() | |
const resArray = new Array(); | |
function rec(){ | |
const firstInQueue = resArray.shift(); | |
if (firstInQueue) | |
firstInQueue.send('Hello World'); | |
setTimeout(rec, 30); | |
} | |
app.get('/', function (req, res) { | |
resArray.push(res); | |
}) | |
app.get('/quick', function (req, res) { | |
res.send('Hello World'); | |
}) | |
app.listen(3000, function () { | |
rec() | |
console.log('Example app listening on port 3000!') | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment