-
Notifications
You must be signed in to change notification settings - Fork 20
/
deezy.js
66 lines (61 loc) · 1.83 KB
/
deezy.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const axios = require('axios')
const packageInfo = require('./package.json')
const BASE_URL = process.env.DEEZY_BASE_URL || 'https://api.deezy.io/v1'
function check_api_key() {
if (!process.env.DEEZY_API_KEY) {
throw new Error('DEEZY_API_KEY must be set')
}
}
async function post_scan_request(request_body) {
check_api_key()
const url = `${BASE_URL}/sat-hunting/scan`
const { data } = await axios
.post(url, request_body, {
headers: {
'x-api-token': process.env.DEEZY_API_KEY,
'User-Agent': `sat-hunter/${packageInfo.version}`, // Include the app version
},
})
.catch((err) => {
console.error(err.data)
return { data: {} }
})
return data
}
async function get_scan_request({ scan_request_id }) {
check_api_key()
const url = `${BASE_URL}/sat-hunting/scan/${scan_request_id}`
const { data } = await axios
.get(url, {
headers: {
'x-api-token': process.env.DEEZY_API_KEY,
'User-Agent': `sat-hunter/${packageInfo.version}`, // Include the app version
},
})
.catch((err) => {
console.error(err.data)
return { data: {} }
})
return data
}
async function get_user_limits() {
check_api_key()
const url = `${BASE_URL}/sat-hunting/user/limits`
const { data } = await axios
.get(url, {
headers: {
'x-api-token': process.env.DEEZY_API_KEY,
'User-Agent': `sat-hunter/${packageInfo.version}`, // Include the app version
},
})
.catch((err) => {
console.error(err)
return { data: {} }
})
return data
}
module.exports = {
post_scan_request,
get_scan_request,
get_user_limits,
}