mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
ad52f7dc01
[misc] add waitForDb wrapper to scripts with indirect mongo access GitOrigin-RevId: 009331f91a45f075a35b0b6e90c4352e55908c21
29 lines
768 B
JavaScript
29 lines
768 B
JavaScript
const { waitForDb } = require('../app/src/infrastructure/mongodb')
|
|
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)
|
|
}
|
|
|
|
waitForDb()
|
|
.then(main)
|
|
.catch(err => {
|
|
console.error(err)
|
|
process.exit(1)
|
|
})
|
|
|
|
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)
|
|
})
|
|
}
|