chore: initial commit for phase03
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import type { FastifyRequest } from 'fastify';
|
||||
import { auditLogs } from '@source/database';
|
||||
import type { Database } from '@source/database';
|
||||
|
||||
export async function createAuditLog(
|
||||
db: Database,
|
||||
request: FastifyRequest,
|
||||
data: {
|
||||
organizationId: string;
|
||||
action: string;
|
||||
serverId?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
},
|
||||
) {
|
||||
await db.insert(auditLogs).values({
|
||||
organizationId: data.organizationId,
|
||||
userId: request.user.sub,
|
||||
serverId: data.serverId,
|
||||
action: data.action,
|
||||
metadata: data.metadata ?? {},
|
||||
ipAddress: request.ip,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user