feathersjs-ecosystem/feathers-authentication-management

View on GitHub
src/helpers/notify.ts

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import makeDebug from 'debug';
import { sanitizeUserForNotifier } from './sanitize-user-for-notifier';

import type { User, Notifier, NotificationType } from '../types';

const debug = makeDebug('authLocalMgnt:notifier');

export async function notify (
  notifier: Notifier,
  type: NotificationType,
  user: User,
  notifierOptions?: Record<string, unknown>
): Promise<User> {
  debug('notifier', type);

  await notifier(type, sanitizeUserForNotifier(user), notifierOptions || {});
  return user;
}