zglos-scammera.ts
const BASE_URL = "https://zglosscammera.pl";
export type ListKind = "scammers" | "servers" | "legit";
export type ListEntry = {
_id: string;
name: string;
id: string;
descHtml: string;
verified: boolean;
proofsId: string | null;
reportId: string;
};
export type ListResponse = {
data: ListEntry[];
total: number;
hasMore: boolean;
};
export type ListParams = {
search?: string;
id?: string;
sort?: "newest" | "oldest" | "popular" | "popular_asc" | "az" | "za";
status?: "all" | "verified" | "risk";
proofs?: "all" | "with" | "private";
skip?: number;
limit?: number;
};
async function request<T>(path: string): Promise<T> {
const res = await fetch(`${BASE_URL}${path}`);
if (!res.ok) {
const body = await res.json().catch(() => ({}));
throw new Error(body.error ?? `HTTP ${res.status}`);
}
return res.json() as Promise<T>;
}
export function getList(kind: ListKind, params: ListParams = {}) {
const query = new URLSearchParams(
Object.entries(params)
.filter(([, value]) => value !== undefined)
.map(([key, value]) => [key, String(value)]),
);
return request<ListResponse>(`/api/${kind}?${query}`);
}
export function check(query: string) {
return request<{ results: { kind: ListKind; entries: ListEntry[] }[] }>(
`/api/check?q=${encodeURIComponent(query)}`,
);
}
Użycie
import { check, getList } from "./zglos-scammera";
const { results } = await check("1478133625840074918");
const isScammer = results.some((result) => result.kind !== "legit");
const page = await getList("scammers", {
status: "verified",
proofs: "with",
limit: 60,
});
console.log(`${page.total} zweryfikowanych oszustów z dowodami`);