77 lines
2.1 KiB
TypeScript
77 lines
2.1 KiB
TypeScript
import type { NextRequest, NextResponse } from 'next/server';
|
|
|
|
import { STATUS, response, handleError } from 'src/utils/response';
|
|
|
|
import { listAccessLogs } from 'src/app/services/AccessLog.service';
|
|
|
|
// import prisma from '../../lib/prisma';
|
|
|
|
export async function GET(req: NextRequest, res: NextResponse) {
|
|
try {
|
|
const result = await listAccessLogs();
|
|
|
|
return response(result, STATUS.OK);
|
|
} catch (error) {
|
|
return handleError('AccessLog - Get all', error);
|
|
}
|
|
}
|
|
|
|
// /**
|
|
// ***************************************
|
|
// * POST - create AccessLog
|
|
// ***************************************
|
|
// */
|
|
// export async function POST(req: NextRequest) {
|
|
// const { data } = await req.json();
|
|
|
|
// try {
|
|
// const createResult = await AccessLogService.create(data);
|
|
|
|
// return response(createResult, STATUS.OK);
|
|
// } catch (error) {
|
|
// return handleError('AccessLog - Create', error);
|
|
// }
|
|
// }
|
|
|
|
// /**
|
|
// ***************************************
|
|
// * PUT - update AccessLog
|
|
// ***************************************
|
|
// */
|
|
// export async function PUT(req: NextRequest) {
|
|
// const { searchParams } = req.nextUrl;
|
|
// const accessLogId = searchParams.get('accessLogId');
|
|
|
|
// const { data } = await req.json();
|
|
|
|
// try {
|
|
// if (!accessLogId) throw new Error('accessLogId cannot be null');
|
|
|
|
// const updateResult = await AccessLogService.update(accessLogId, data);
|
|
|
|
// return response(updateResult, STATUS.OK);
|
|
// } catch (error) {
|
|
// return handleError('AccessLog - Update', error);
|
|
// }
|
|
// }
|
|
|
|
// /**
|
|
// ***************************************
|
|
// * DELETE - delete AccessLog
|
|
// ***************************************
|
|
// */
|
|
// export async function DELETE(req: NextRequest) {
|
|
// const { searchParams } = req.nextUrl;
|
|
// const accessLogId = searchParams.get('accessLogId');
|
|
|
|
// try {
|
|
// if (!accessLogId) throw new Error('accessLogId cannot be null');
|
|
|
|
// const deleteResult = await AccessLogService.delete(accessLogId);
|
|
|
|
// return response(deleteResult, STATUS.OK);
|
|
// } catch (error) {
|
|
// return handleError('AccessLog - Delete', error);
|
|
// }
|
|
// }
|