Add delete all apps script
This commit is contained in:
parent
becb7bd46d
commit
3824156ca5
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/node
|
||||||
|
const { searchApps, deleteApp } = require("./utils")
|
||||||
|
|
||||||
|
if (!process.argv[2]) {
|
||||||
|
console.error("Please specify an API key as script argument.")
|
||||||
|
process.exit(-1)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
const apiKey = process.argv[2]
|
||||||
|
const apps = await searchApps(apiKey)
|
||||||
|
console.log(`Deleting ${apps.length} apps`)
|
||||||
|
|
||||||
|
let deletedApps = 0
|
||||||
|
await Promise.all(
|
||||||
|
apps.map(async app => {
|
||||||
|
await deleteApp(apiKey, app._id)
|
||||||
|
console.log(`App ${++deletedApps} of ${apps.length} deleted`)
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
run()
|
||||||
|
.then(() => {
|
||||||
|
console.log("Done!")
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
|
@ -38,6 +38,17 @@ exports.createApp = async apiKey => {
|
||||||
return json.data
|
return json.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.searchApps = async apiKey => {
|
||||||
|
const res = await request(apiKey, `${URL_APP}/search`, "POST", {})
|
||||||
|
const json = await res.json()
|
||||||
|
return json.data
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.deleteApp = async (apiKey, appId) => {
|
||||||
|
const res = await request(apiKey, `${URL_APP}/${appId}`, "DELETE")
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
exports.getTable = async (apiKey, appId) => {
|
exports.getTable = async (apiKey, appId) => {
|
||||||
const res = await request(apiKey, URL_SEARCH_TABLE, "POST", {}, appId)
|
const res = await request(apiKey, URL_SEARCH_TABLE, "POST", {}, appId)
|
||||||
const json = await res.json()
|
const json = await res.json()
|
||||||
|
|
Loading…
Reference in New Issue