// src/app/services/AccessLog.service.ts // // PURPOSE: // Service for handling AccessLog records // // RULES: // - All methods return Promises // - Input validation should be done at controller level // - Errors should be propagated to caller import type { AccessLog } from '@prisma/client'; import prisma from '../lib/prisma'; // type CreateAccessLog = { // userId?: string; // message?: string; // metadata?: Record; // }; // type UpdateAccessLog = { // status?: number; // metadata?: object; // }; async function listAccessLogs(): Promise { return prisma.accessLog.findMany({ orderBy: { timestamp: 'desc' }, take: 100, }); } async function getAccessLog(id: string): Promise { return prisma.accessLog.findUnique({ where: { id } }); } async function createAccessLog(userId?: string, message?: string, metadata?: Record): Promise { return prisma.accessLog.create({ data: { userId, message, metadata, }, }); } // async function update(id: string, data: UpdateAccessLog): Promise { // return prisma.accessLog.update({ // where: { id }, // data: { // ...data, // metadata: data.metadata || {}, // }, // }); // } // async function deleteAccessLog(id: string): Promise { // return prisma.accessLog.delete({ where: { id } }); // } export { // getAccessLog, listAccessLogs, createAccessLog, };