In order to test some of the concepts regarding sync vs async functions in node.js I would like to create an example emulating a blocking function, how can I achieve this? More specific, I want to demonstrate that using Express I can implement two GET requests, where the first one blocks the second one when executed in parallel. How should blockingFunctionHere in the following example looks like:
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/1', function(req, res, next) {
blockingFunctionHere(); // emulate a blocking function for some seconds, let's say 10 seconds
res.render('index', { title: 'Coming from request #1' });
});
router.get('/2', function(req, res, next) {
res.render('index', { title: 'Coming from request #2' })
});
module.exports = router;