const Objection = require('objection') const Schmervice = require('@hapipal/schmervice') const ProfileModel = require('../models/profile') const ResponseModel = require('../models/response') const ProfileService = require('../services/profile') const ProfileProfilesRoute = require('../routes/profile/profiles') const ProfileCreateRoute = require('../routes/profile/create') module.exports = { name: 'profile-plugin', version: '1.0.0', register: async (server, options) => { await server.registerModel(ProfileModel) await server.registerModel(ResponseModel) // Bind to global context // So we can use Objection transactions server.bind({ transaction: fn => Objection.transaction(server.knex(), fn), }) await server.register(Schmervice) server.registerService(ProfileService) await server.route(ProfileProfilesRoute) await server.route(ProfileCreateRoute) }, }