Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var obs = {
type: 'observation',
lat: 0.4,
lon: 1,
attachments: [ {
id: obj.id
}]
}
hq.end(JSON.stringify(obs))
}))
hq.end()
var hq2 = hyperquest.get(base + '/sync/announce', {})
hq2.pipe(concat({ encoding: 'string' }, function (body) {
console.log(body)
}))
hq2.end()
})
function verify (port, stream) {
function error (err) {
const msg = exercise.__('fail.cannot_connect', port, err.code);
exercise.emit('fail', msg);
}
hyperquest.get(`http://localhost:${port}/`)
.on('error', error)
.pipe(bl((err, data) => {
if (err) return stream.emit('error', err);
stream.write(`${data.toString()}\n`);
stream.end();
}));
}
function verify (port, stream) {
function error (err) {
const msg = exercise.__('fail.cannot_connect', port, err.code);
exercise.emit('fail', msg);
}
hyperquest.get(`http://localhost:${port}/world`)
.on('error', error)
.pipe(bl((err, data) => {
if (err) return stream.emit('error', err);
stream.write(`${data.toString()}\n`);
stream.end();
}));
}
.pipe(bl(function (err, data) {
if (err)
return output.emit('error', err)
output.write(data.toString() + '\n')
hyperquest.get('http://localhost:' + port + '/api/unixtime?iso=' + date.toISOString())
.on('error', error)
.pipe(bl(function (err, data) {
if (err)
return output.emit('error', err)
output.write(data.toString() + '\n')
output.end()
}))
}))
return output
function connect (port, stream) {
//TODO: introduce verification of content-type:text/plain and statusCode=200
hyperquest.get('http://localhost:' + port)
.on('error', function (err) {
exercise.emit(
'fail'
, 'Error connecting to http://localhost:' + port + ': ' + err.message
)
})
.pipe(stream)
}
function verify (port, stream) {
const url = `http://localhost:${port}/chickens`;
function error (err) {
const msg = exercise.__('fail.cannot_connect', port, err.code);
exercise.emit('fail', msg);
}
hyperquest.get(url)
.on('error', error)
.pipe(bl((err, data) => {
if (err) return stream.emit('error', err);
stream.write(`${data.toString()}\n`);
stream.end();
}));
}
setTimeout(function () {
hyperquest.get('http://localhost:8000')
.on('error', error.bind(null, 'http://localhost:8000', outputA))
.pipe(outputA)
if (!run) {
hyperquest.get('http://localhost:8001')
.on('error', error.bind(null, 'http://localhost:8001', outputB))
.pipe(outputB)
}
}, 500)
setTimeout(function () {
hyperquest.get('http://localhost:8000')
.on('error', error.bind(null, 'http://localhost:8000', outputA))
.pipe(outputA)
if (!run) {
hyperquest.get('http://localhost:8001')
.on('error', error.bind(null, 'http://localhost:8001', outputB))
.pipe(outputB)
}
}, 500)
var doRequest = function () {
hyperquest.get(url).pipe(bl(function (err, data) {
if (err !== null) {
attempt++;
if (attempt < 100) {
setTimeout(doRequest, 100);
} else {
hyperquest.get(url).pipe(bl(onData));
}
} else {
hyperquest.get(url).pipe(bl(onData));
}
}));
};
var doRequest = function () {
hyperquest.get(url).pipe(bl(function (err, data) {
if (err !== null) {
attempt++;
if (attempt < 100) {
setTimeout(doRequest, 100);
} else {
hyperquest.get(url).pipe(bl(onData));
}
} else {
hyperquest.get(url).pipe(bl(onData));
}
}));
};