Skip to content

Commit 263ed42

Browse files
committed
feat: mark anonymous requests
1 parent 57d9683 commit 263ed42

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hooks/logging.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { HookContext } from '@feathersjs/feathers';
22

33
export default async (context: HookContext): Promise<HookContext> => {
44
if (context.params.provider) {
5-
const { method, path, id, params: { user: { username }} } = context;
5+
const { method, path, id } = context;
66
const timestamp = new Date().toLocaleString('default', { timeStyle: 'medium', dateStyle: 'short' });
77
const message = `${method.toUpperCase()}: /${path}/${id || ''}`;
8+
const username = context.params.user?.username || 'anonymous';
89

9-
console.log(`[${timestamp}] ${message} ${username || ''}`);
10+
console.log(`[${timestamp}] ${message} ${username}`);
1011
}
1112
return context;
1213
};

0 commit comments

Comments
 (0)