-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (31 loc) · 1.06 KB
/
index.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
const fetch = require('node-fetch');
const config = require('./config.json');
fetch(`${config.url}api/application/servers`, {
method: 'GET',
headers: {
'Authorization': `Bearer ${config.api}`,
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
const getto = data.data.filter(server => !server.attributes.name.includes(config.keyword));
getto.foreach(server => {
fetch(`${config.url}api/application/servers/${server.attributes.id}`, {
method: 'DELETE',
headers: {
'Authorization': `Bearer ${config.api}`,
'Content-Type': 'application/json'
}
})
.then(response => {
console.log(`Server ${server.attributes.name} has been gased.`);
})
.catch(error => {
console.log(`An error allowed this server to escape the gas ${server.attributes.name}: ${error}`);
});
});
})
.catch(error => {
console.log(`An error has been spotted causing havoc in the process: ${error}`);
});