remove_oauth_application.mjs 813 B

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