aboutsummaryrefslogtreecommitdiff
path: root/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'hooks')
-rw-r--r--hooks/logging.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/hooks/logging.ts b/hooks/logging.ts
new file mode 100644
index 0000000..30353ae
--- /dev/null
+++ b/hooks/logging.ts
@@ -0,0 +1,13 @@
+import { HookContext } from '@feathersjs/feathers';
+
+export default async (context: HookContext): Promise<HookContext> => {
+ if (context.params.provider) {
+ const { method, path, id, params: { user: { username }} } = context;
+ const timestamp = new Date().toLocaleString('default', { timeStyle: 'medium', dateStyle: 'short' });
+ const message = `${method.toUpperCase()}: /${path}/${id || ''}`;
+
+ console.log(`[${timestamp}] ${message} ${username || ''}`);
+ }
+ return context;
+};
+