You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

profile.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const Objection = require('objection')
  2. const Schmervice = require('@hapipal/schmervice')
  3. const ProfileModel = require('../models/profile')
  4. const TagModel = require('../models/tag')
  5. const TagAssociationModel = require('../models/tag-association')
  6. const AspectModel = require('../models/aspect')
  7. const AspectLabelModel = require('../models/aspect_label')
  8. const ResponseModel = require('../models/response')
  9. const ZipCodeModel = require('../models/zip-code')
  10. const MatchQueueModel = require('../models/matchqueue')
  11. const ProfileService = require('../services/profile')
  12. const MatchQueueService = require('../services/matchqueue')
  13. const MatchService = require('../services/match')
  14. const ProfileScoreRoute = require('../routes/profile/score')
  15. const ProfileUpdateRoute = require('../routes/profile/update')
  16. const ProfileInsertRoute = require('../routes/profile/insert')
  17. const ProfileRespondRoute = require('../routes/profile/respond')
  18. const ProfileMatchRoute = require('../routes/profile/match')
  19. const ProfileQueueRoute = require('../routes/profile/queue')
  20. const ProfileGetRoute = require('../routes/profile/get')
  21. const ProfilePatchQueueRoute = require('../routes/profile/patch-queue')
  22. const TagRevealRoute = require('../routes/tag/reveal')
  23. const TagGetRoute = require('../routes/tag/get')
  24. module.exports = {
  25. name: 'profile-plugin',
  26. version: '1.0.0',
  27. register: async (server, options) => {
  28. await server.registerModel(ProfileModel)
  29. await server.registerModel(TagModel)
  30. await server.registerModel(TagAssociationModel)
  31. await server.registerModel(AspectModel)
  32. await server.registerModel(AspectLabelModel)
  33. await server.registerModel(ResponseModel)
  34. await server.registerModel(ZipCodeModel)
  35. await server.registerModel(MatchQueueModel)
  36. // Bind to global context
  37. // So we can use Objection transactions
  38. server.bind({
  39. transaction: fn => Objection.transaction(server.knex(), fn),
  40. })
  41. await server.register(Schmervice)
  42. await server.registerService(ProfileService)
  43. await server.registerService(MatchQueueService)
  44. await server.registerService(MatchService)
  45. await server.route(ProfileScoreRoute)
  46. await server.route(ProfileRespondRoute)
  47. await server.route(ProfileUpdateRoute)
  48. await server.route(ProfileInsertRoute)
  49. await server.route(ProfileMatchRoute)
  50. await server.route(ProfileQueueRoute)
  51. await server.route(ProfileGetRoute)
  52. await server.route(ProfilePatchQueueRoute)
  53. await server.route(TagRevealRoute)
  54. await server.route(TagGetRoute)
  55. },
  56. }