Testing out a new module for channels api hits

This commit is contained in:
shockrah 2021-01-28 17:56:40 -08:00
parent 91a4e06cb7
commit ac9668557b

View File

@ -0,0 +1,49 @@
// Requesting channel data here
const auth = require('./auth.js')
const { Request } = require('./request.js')
class Channel {
constructor(name, id, type, description) {
this.name = name
this.id = id
this.type = type
this.description = description
}
}
/**
*
* @param {String} domain | domain of the instance we're looking at
* @param {Number} port | Should always be the default value of 4536 but other owner
* @param {Object} params | basic object with jwt + id fields
*/
function channels_list(domain, port, params) {
const url = `http://${domain}:${port}/channels/list` // input sanitzation is for bitches
Request('get', url, params).then(
response => {
const channels = response.body
console.log(channels)
},
reason => {
}
)
}
/**
* Only requests
* @param {Object} server_conf Should contain at least id/secret + domain/port
*
*/
exports.get_channels = function(server_conf) {
// the first two checks are here to rpevent getting a 401 due to a bad/missing jwt
if('jwt' in server_conf) {
if(auth.valid_jwt(server['jwt'])) {
const params = { jwt: server['jwt'], id: server['id'] }
}
// do something else idk
} else {
// complain here
}
}