0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00
verdaccio/test/functional/fixtures/plugins/middlewares.uplink.js
2019-09-26 18:22:14 +02:00

27 lines
702 B
JavaScript

/* eslint-disable @typescript-eslint/no-var-requires */
const nock = require('nock');
function Plugin(config) {
const self = Object.create(Plugin.prototype);
self._config = config;
return self;
}
Plugin.prototype.register_middlewares = function (app) {
app.get('/test-uplink-timeout-*', function (req, res, next) {
// https://github.com/nock/nock#readme
nock('http://localhost:55552')
.get(req.path)
// note: we use 50s due hardware reasons small threshold is not enough to make fails
// 50s is greater than the default 30s connection timeout
.socketDelay(50000)
// http-status 200 OK
.reply(200);
next();
});
};
module.exports = Plugin;