aboutsummaryrefslogtreecommitdiff
path: root/hooks/logging.ts
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/logging.ts')
-rw-r--r--hooks/logging.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/hooks/logging.ts b/hooks/logging.ts
new file mode 100644
index 0000000..8babe9a
--- /dev/null
+++ b/hooks/logging.ts
@@ -0,0 +1,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;
+};
+