Skip to content

Instantly share code, notes, and snippets.

@Mattchewone Mattchewone/hooks.js Secret
Created Feb 22, 2019

What would you like to do?
Example hook file
create: [
async context => {
const { app, data, params } = context
// Exit if no provider
// only run for external access
if (!params.provider) {
return context
// Load the group so we can emit this value to the client
const group = await app.service('groups').get(data.groupId, context.params)
if (group) {
// Emit a created event, so we can publish this to the user
const service = app.service('groups')
await service.emit('created', group, Object.assign({}, context, { path: 'groups', hookEmit: true, userId: data.userId }))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.