aboutsummaryrefslogtreecommitdiff
path: root/hooks
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-25 19:41:42 +0300
committereug-vs <eug-vs@keemail.me>2020-06-25 19:41:42 +0300
commit57d96831358a6df5dd4f92a1d33715cbc3a575e0 (patch)
tree5799a6d9eb60aa870c49337edcd9aa82473979fc /hooks
parent343a975413d8d3ce8194507017fb4ca01a4faf54 (diff)
downloadwhich-api-57d96831358a6df5dd4f92a1d33715cbc3a575e0.tar.gz
feat: enable logging hook for external requests
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;
+};
+