MCPcopy Index your code
hub / github.com/restify/node-restify / setupClientServer

Function setupClientServer

test/plugins/throttle.test.js:19–52  ·  view source on GitHub ↗
(ip, throttleOptions, done)

Source from the content-addressed store, hash-verified

17var errorMessage = 'Error message should include rate 0.5 r/s. Received: ';
18
19function setupClientServer(ip, throttleOptions, done) {
20 var server = restify.createServer({
21 dtrace: helper.dtrace,
22 log: helper.getLog('server')
23 });
24
25 server.use(function ghettoAuthenticate(req, res, next) {
26 var username = req.url.match(/test\/([a-z]+)/)[1];
27
28 if (username) {
29 req.username = username;
30 }
31
32 next();
33 });
34
35 server.use(restify.plugins.throttle(throttleOptions));
36
37 server.get('/test/:name', function(req, res, next) {
38 res.send();
39 next();
40 });
41
42 server.listen(PORT, ip, function() {
43 PORT = server.address().port;
44 var client = restifyClients.createJsonClient({
45 url: 'http://' + ip + ':' + PORT,
46 dtrace: helper.dtrace,
47 retry: false
48 });
49
50 done(client, server);
51 });
52}
53
54///--- Tests
55

Callers 1

throttle.test.jsFile · 0.85

Calls 2

doneFunction · 0.85
nextFunction · 0.70

Tested by

no test coverage detected