Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
akupiec
GitHub Repository: akupiec/mad-proxy
Path: blob/master/src/middlewares/mockGeter.js
115 views
1
const fs = require('fs');
2
const LOGGER = require('../config/logger');
3
4
module.exports = function (proxyConfig) {
5
return function mockGeter(req, res, next) {
6
if(req.mock.mockExists && proxyConfig.cache.enabled) {
7
LOGGER.debug('Sending from mock', req.mock.filePath);
8
let readStream = fs.createReadStream(req.mock.filePath);
9
res.status(200);
10
readStream.pipe(res);
11
return;
12
}
13
next();
14
};
15
};
16
17