aboutsummaryrefslogtreecommitdiff
path: root/hooks/logging.ts
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-06-25 19:44:12 +0300
committereug-vs <eug-vs@keemail.me>2020-06-25 19:44:12 +0300
commit263ed426cc5ea79d36bca2b82a8aa858e43072eb (patch)
treeab6e1925c98f177f880741f4e637ce56214f1fb4 /hooks/logging.ts
parent57d96831358a6df5dd4f92a1d33715cbc3a575e0 (diff)
downloadwhich-api-263ed426cc5ea79d36bca2b82a8aa858e43072eb.tar.gz
feat: mark anonymous requests
Diffstat (limited to 'hooks/logging.ts')
-rw-r--r--hooks/logging.ts5
1 files changed, 3 insertions, 2 deletions
diff --git a/hooks/logging.ts b/hooks/logging.ts
index 30353ae..840873c 100644
--- a/hooks/logging.ts
+++ b/hooks/logging.ts
@@ -2,11 +2,12 @@ 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 { method, path, id } = context;
const timestamp = new Date().toLocaleString('default', { timeStyle: 'medium', dateStyle: 'short' });
const message = `${method.toUpperCase()}: /${path}/${id || ''}`;
+ const username = context.params.user?.username || 'anonymous';
- console.log(`[${timestamp}] ${message} ${username || ''}`);
+ console.log(`[${timestamp}] ${message} ${username}`);
}
return context;
};