add admin checks for admin pages and run biome formating 🔨

This commit is contained in:
2025-07-25 13:31:12 +05:00
parent aedf7cdf7d
commit 9b2f2c1528
127 changed files with 6572 additions and 6329 deletions
+3 -3
View File
@@ -3,7 +3,9 @@ import type { TNationalPerson } from "@/lib/types";
export async function getNationalPerson({
idCard,
}: { idCard: string }): Promise<TNationalPerson> {
}: {
idCard: string;
}): Promise<TNationalPerson> {
const nationalInformation = await fetch(
`${process.env.PERSON_VERIFY_BASE_URL}/api/person/${idCard}`,
{
@@ -15,5 +17,3 @@ export async function getNationalPerson({
const nationalData = (await nationalInformation.json()) as TNationalPerson;
return nationalData;
}
+3 -3
View File
@@ -6,13 +6,13 @@ export type Transaction = {
ref: string;
sourceBank: string;
trxDate: string;
}
};
export type TopupResponse = {
status: boolean;
message: string;
transaction?: Transaction
}
transaction?: Transaction;
};
interface IpAddress {
ip: string;
+27 -27
View File
@@ -2,47 +2,47 @@ import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
return twMerge(clsx(inputs));
}
export const formatDate = (date: Date): string => {
const pad = (num: number): string => num.toString().padStart(2, "0");
const pad = (num: number): string => num.toString().padStart(2, "0");
const year = date.getFullYear();
const month = pad(date.getMonth() + 1); // Months are zero-based
const day = pad(date.getDate());
const hours = pad(date.getHours());
const minutes = pad(date.getMinutes() + 5);
const year = date.getFullYear();
const month = pad(date.getMonth() + 1); // Months are zero-based
const day = pad(date.getDate());
const hours = pad(date.getHours());
const minutes = pad(date.getMinutes() + 5);
return `${year}-${month}-${day} ${hours}:${minutes}`;
return `${year}-${month}-${day} ${hours}:${minutes}`;
};
export const formatMacAddress = (mac: string): string => {
const formatted = mac
.replace(/[^A-Fa-f0-9]/g, "")
.toUpperCase()
.match(/.{2}/g);
const formatted = mac
.replace(/[^A-Fa-f0-9]/g, "")
.toUpperCase()
.match(/.{2}/g);
// Provide a fallback if formatted is null
return formatted ? formatted.join("-") : "";
// Provide a fallback if formatted is null
return formatted ? formatted.join("-") : "";
};
export function validateApiKey(request: Request) {
// Get API key from environment variable
const validApiKey = process.env.CRON_API_KEY;
// Get API key from environment variable
const validApiKey = process.env.CRON_API_KEY;
if (!validApiKey) {
throw new Error("CRON_API_KEY is not configured");
}
if (!validApiKey) {
throw new Error("CRON_API_KEY is not configured");
}
// Get API key from request header
const apiKey = request.headers.get("x-api-key");
// Get API key from request header
const apiKey = request.headers.get("x-api-key");
if (!apiKey) {
throw new Error("API key is missing");
}
if (!apiKey) {
throw new Error("API key is missing");
}
if (apiKey !== validApiKey) {
throw new Error("Invalid API key");
}
if (apiKey !== validApiKey) {
throw new Error("Invalid API key");
}
}