選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

profile.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. const Objection = require('objection')
  2. const Schmervice = require('@hapipal/schmervice')
  3. const ProfileModel = require('../models/profile')
  4. const ResponseModel = require('../models/response')
  5. const ProfileService = require('../services/profile')
  6. const ProfileScoreRoute = require('../routes/profile/score')
  7. const ProfileUpdateRoute = require('../routes/profile/update')
  8. const ProfileRespondRoute = require('../routes/profile/respond')
  9. module.exports = {
  10. name: 'profile-plugin',
  11. version: '1.0.0',
  12. register: async (server, options) => {
  13. await server.registerModel(ProfileModel)
  14. await server.registerModel(ResponseModel)
  15. // Bind to global context
  16. // So we can use Objection transactions
  17. server.bind({
  18. transaction: fn => Objection.transaction(server.knex(), fn),
  19. })
  20. await server.register(Schmervice)
  21. server.registerService(ProfileService)
  22. await server.route(ProfileScoreRoute)
  23. await server.route(ProfileRespondRoute)
  24. await server.route(ProfileUpdateRoute)
  25. },
  26. }