OauthAccessToken.js 992 B

123456789101112131415161718192021222324252627282930313233
  1. // TODO: This file was created by bulk-decaffeinate.
  2. // Sanity-check the conversion and remove this comment.
  3. const mongoose = require('mongoose')
  4. const Settings = require('settings-sharelatex')
  5. const { Schema } = mongoose
  6. const { ObjectId } = Schema
  7. const OauthAccessTokenSchema = new Schema(
  8. {
  9. accessToken: String,
  10. accessTokenExpiresAt: Date,
  11. oauthApplication_id: { type: ObjectId, ref: 'OauthApplication' },
  12. refreshToken: String,
  13. refreshTokenExpiresAt: Date,
  14. scope: String,
  15. user_id: { type: ObjectId, ref: 'User' }
  16. },
  17. {
  18. collection: 'oauthAccessTokens'
  19. }
  20. )
  21. const conn = mongoose.createConnection(Settings.mongo.url, {
  22. server: { poolSize: Settings.mongo.poolSize || 10 },
  23. config: { autoIndex: false }
  24. })
  25. const OauthAccessToken = conn.model('OauthAccessToken', OauthAccessTokenSchema)
  26. mongoose.model('OauthAccessToken', OauthAccessTokenSchema)
  27. exports.OauthAccessToken = OauthAccessToken
  28. exports.OauthAccessTokenSchema = OauthAccessTokenSchema