remove_oauth_application.mjs 933 B

123456789101112131415161718192021222324252627282930313233343536
  1. import { OauthApplication } from '../app/src/models/OauthApplication.js'
  2. import parseArgs from 'minimist'
  3. import OError from '@overleaf/o-error'
  4. import { waitForDb } from '../app/src/infrastructure/mongodb.js'
  5. async function _removeOauthApplication(appId) {
  6. if (!appId) {
  7. throw new OError('No app id supplied')
  8. }
  9. console.log('Waiting for db...')
  10. await waitForDb()
  11. console.log(`Removing oauthApplication with id=${appId}`)
  12. const result = await OauthApplication.deleteOne({ id: appId })
  13. console.log('Result', result)
  14. }
  15. async function main() {
  16. const argv = parseArgs(process.argv.slice(2), {
  17. string: ['id'],
  18. unknown: function (arg) {
  19. console.error('unrecognised argument', arg)
  20. process.exit(1)
  21. },
  22. })
  23. const appId = argv.id
  24. await _removeOauthApplication(appId)
  25. }
  26. try {
  27. await main()
  28. console.log('Done')
  29. process.exit(0)
  30. } catch (error) {
  31. console.error(error)
  32. process.exit(1)
  33. }