-
-
Save Mattchewone/70b46bcdb0a66de03740f0d6d478d9cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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