chore: code cleaning (#21)

This commit is contained in:
Riccardo Senica
2024-11-23 09:13:15 +01:00
committed by GitHub
parent c4f03feffe
commit c300b2501d
31 changed files with 903 additions and 872 deletions

View File

@@ -1,5 +1,5 @@
import prisma from '@prisma/prisma';
import { ApiResponse } from '@utils/apiResponse';
import { formatApiResponse } from '@utils/formatApiResponse';
import {
INTERNAL_SERVER_ERROR,
STATUS_INTERNAL_SERVER_ERROR,
@@ -15,7 +15,7 @@ export async function GET(request: NextRequest) {
if (
request.headers.get('Authorization') !== `Bearer ${process.env.CRON_SECRET}`
) {
return ApiResponse(STATUS_UNAUTHORIZED, 'Unauthorized');
return formatApiResponse(STATUS_UNAUTHORIZED, 'Unauthorized');
}
try {
@@ -76,9 +76,15 @@ export async function GET(request: NextRequest) {
});
}
return ApiResponse(STATUS_OK, `Imported ${newsPromises.length} news.`);
return formatApiResponse(
STATUS_OK,
`Imported ${newsPromises.length} news.`
);
} catch (error) {
console.error(error);
return ApiResponse(STATUS_INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR);
return formatApiResponse(
STATUS_INTERNAL_SERVER_ERROR,
INTERNAL_SERVER_ERROR
);
}
}