Ind.ie is now Small Technology Foundation.
Commit 26c6d58f authored by Aral Balkan's avatar Aral Balkan

Fix linting errors

parent 2cc2adcf
// Application hooks that run for every service
const logger = require('./hooks/logger');
const logger = require('./hooks/logger')
module.exports = {
before: {
......@@ -31,4 +31,4 @@ module.exports = {
patch: [],
remove: []
}
};
}
module.exports = function(app) {
if(typeof app.channel !== 'function') {
module.exports = function (app) {
if (typeof app.channel !== 'function') {
// If no real-time functionality has been configured just return
return;
return
}
app.on('connection', connection => {
// On a new real-time connection, add it to the anonymous channel
app.channel('anonymous').join(connection);
});
app.channel('anonymous').join(connection)
})
app.on('login', (authResult, { connection }) => {
// connection can be undefined if there is no
// real-time connection, e.g. when logging in via REST
if(connection) {
if (connection) {
// Obtain the logged in user from the connection
// const user = connection.user;
// The connection is no longer anonymous, remove it
app.channel('anonymous').leave(connection);
app.channel('anonymous').leave(connection)
// Add it to the authenticated user channel
app.channel('authenticated').join(connection);
app.channel('authenticated').join(connection)
// Channels can be named anything and joined on any condition
// Channels can be named anything and joined on any condition
// E.g. to send real-time events only to admins use
// if(user.isAdmin) { app.channel('admins').join(connection); }
// If the user has joined e.g. chat rooms
// if(Array.isArray(user.rooms)) user.rooms.forEach(room => app.channel(`rooms/${room.id}`).join(channel));
// Easily organize users by email and userid for things like messaging
// app.channel(`emails/${user.email}`).join(channel);
// app.channel(`userIds/$(user.id}`).join(channel);
}
});
})
app.publish((data, hook) => { // eslint-disable-line no-unused-vars
// Here you can add event publishers to channels set up in `channels.js`
......@@ -43,13 +43,13 @@ module.exports = function(app) {
console.log('Publishing all events to all authenticated users. See `channels.js` and https://docs.feathersjs.com/api/channels.html for more information.'); // eslint-disable-line
// e.g. to publish all service events to all authenticated users use
return app.channel('authenticated');
});
return app.channel('authenticated')
})
// Here you can also add service specific event publishers
// e..g the publish the `users` service `created` event to the `admins` channel
// app.service('users').publish('created', () => app.channel('admins'));
// With the userid and email organization from above you can easily select involved users
// app.service('messages').publish(() => {
// return [
......@@ -57,4 +57,4 @@ module.exports = function(app) {
// app.channel(`emails/${data.recipientEmail}`)
// ];
// });
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment