2020-10-05 08:29:37 +00:00
|
|
|
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
2019-10-14 13:22:45 +00:00
|
|
|
const ProjectDetailsHandler = require('../app/src/Features/Project/ProjectDetailsHandler')
|
|
|
|
const projectId = process.argv[2]
|
|
|
|
|
|
|
|
if (!/^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)/.test(projectId)) {
|
|
|
|
console.error('Usage: node clear_project_tokens.js projectId')
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
|
2020-10-05 08:29:37 +00:00
|
|
|
waitForDb()
|
|
|
|
.then(main)
|
|
|
|
.catch(err => {
|
|
|
|
console.error(err)
|
2019-10-14 13:22:45 +00:00
|
|
|
process.exit(1)
|
2020-10-05 08:29:37 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
ProjectDetailsHandler.clearTokens(projectId, err => {
|
|
|
|
if (err) {
|
|
|
|
console.error(
|
|
|
|
`Error clearing project tokens from project ${projectId}`,
|
|
|
|
err
|
|
|
|
)
|
|
|
|
process.exit(1)
|
|
|
|
}
|
|
|
|
console.log(`Successfully cleared project tokens from project ${projectId}`)
|
|
|
|
process.exit(0)
|
|
|
|
})
|
|
|
|
}
|