aboutsummaryrefslogtreecommitdiff
path: root/hooks/logging.ts
blob: 8babe9a42375fe746b18b3298c53210ede6d323e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { HookContext } from '@feathersjs/feathers';
import logger from '../logger';

export default async (context: HookContext): Promise<HookContext> => {
  if (context.params.provider) {
    const { method, path, id } = context;
    const message = `${method.toUpperCase()}: /${path}/${id || ''}`;
    const username = context.params.user?.username || 'anonymous';

    logger.log(`${message} ${username}`);
  }
  return context;
};