Skip to content

Instantly share code, notes, and snippets.

@Mattchewone
Created December 6, 2018 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mattchewone/70b46bcdb0a66de03740f0d6d478d9cb to your computer and use it in GitHub Desktop.
Save Mattchewone/70b46bcdb0a66de03740f0d6d478d9cb to your computer and use it in GitHub Desktop.
// Initializes the `messages` service on path `/messages`
const createService = require('feathers-nedb')
const createModel = require('../../models/messages.model')
const hooks = require('./messages.hooks')
module.exports = function (app) {
const Model = createModel(app)
const paginate = app.get('paginate')
const options = {
Model,
paginate
}
// Initialize our service with any options it requires
app.use('/messages', createService(options))
// Get our initialized service so that we can register hooks
const service = app.service('messages')
service.hooks(hooks)
// Override the default publish so we only send data within
// these channels
service.publish((data, hook) => {
return app.channel(`userIds/${data.to}`)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment