22 lines
644 B
JavaScript
22 lines
644 B
JavaScript
const applyIOHelpers = ({ app, api, io, logger }) => {
|
|
const getBodyshopRoom = (bodyshopID) => `bodyshop-broadcast-room:${bodyshopID}`;
|
|
// Messaging - conversation specific room to handle detailed messages when the user has a conversation open.
|
|
const getBodyshopConversationRoom = ({bodyshopId, conversationId}) =>
|
|
`bodyshop-conversation-room:${bodyshopId}:${conversationId}`;
|
|
|
|
const ioHelpersAPI = {
|
|
getBodyshopRoom,
|
|
getBodyshopConversationRoom
|
|
};
|
|
|
|
// Helper middleware
|
|
app.use((req, res, next) => {
|
|
req.ioHelpers = ioHelpersAPI;
|
|
next();
|
|
});
|
|
|
|
return ioHelpersAPI;
|
|
};
|
|
|
|
module.exports = { applyIOHelpers };
|