-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathchans.js
38 lines (35 loc) · 1 KB
/
chans.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
const config = require('../config')
const Tile38 = require('tile38');
const Tile38client = new Tile38(config.tile38);
// route schema
const schema = {
description: 'Return list of object collections',
tags: ['feature'],
summary: 'return a list of Tile38 object collections'
}
module.exports = function (fastify, opts, next) {
fastify.route({
method: 'GET',
url: '/chans',
schema: schema,
handler: function (request, reply) {
let chans = Tile38client.sendCommand('CHANS', 'chans', '*');
chans.then(results => {
console.dir(results);
reply.type('application/json').send(results);
}).catch(err => {
console.error("something went wrong! " + err);
});
/*
chans.then(results => {
console.dir(results.count,{depth:6}); // results is an object.
reply.type('application/json').send(results);
}).catch(err => {
console.error("something went wrong! " + err);
});
*/
}
})
next()
}
module.exports.autoPrefix = '/v1'