-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreader.js
49 lines (41 loc) · 1.5 KB
/
reader.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var express = require('express');
var request = require('request');
var app = express();
var MAX_INT = 4294967295;
var r = Math.floor(Math.random() * MAX_INT);
console.log("Start");
request('http://localhost:3000/query/' + r, function (error, response, body) {
if (error) console.log(error);
else if (response.statusCode == 200) {
var post_data = JSON.parse(body);
post_data.N_r = r;
var options = {
uri: 'http://localhost:3001/query',
method: 'GET',
json: post_data
};
request(options, function (error, response, body) {
if (error) console.log(error);
else if (response.statusCode == 200) {
var auth_data = body;
var auth_options = {
uri: 'http://localhost:3000/authenticate',
method: 'GET',
json: auth_data
};
request(auth_options, function (error, response, body) {
if (error) console.log(error);
else if (response.statusCode == 200) {
console.log('success');
} else {
console.log('Authentication failed: ' + response.statusCode);
}
})
} else {
console.log('Database query failed: ' + response.statusCode);
}
});
} else {
console.log('Tag query failed: ' + response.statusCode);
}
});