Add api logging
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
import { getUserSession } from '#imports';
|
||||||
|
|
||||||
|
export default defineEventHandler(async (event) => {
|
||||||
|
const { method, path } = event;
|
||||||
|
if (path.startsWith('/api/metrics')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const { user } = await getUserSession(event);
|
||||||
|
const ip = getRequestIP(event, { xForwardedFor: true });
|
||||||
|
|
||||||
|
console.log('--> ', ip ?? '???', user?.id ?? 'Anon', method, path);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user