Write interfaces and fetch logic for fetching github stats, privacy policy info, and website metrics for each service
This commit is contained in:
parent
6bf594654d
commit
c80742633f
|
@ -0,0 +1,61 @@
|
||||||
|
|
||||||
|
export const fetchTosdrPrivacy = async (serviceId: string): Promise<PrivacyPolicyResponse | null> => {
|
||||||
|
const endpoint = `https://api.tosdr.org/service/v2?id=${serviceId}`;
|
||||||
|
try {
|
||||||
|
return await fetch(endpoint).then((res) => res.json());
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching privacy policy data:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
interface Document {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
updated_at: string;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Case {
|
||||||
|
id: number;
|
||||||
|
weight: number;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
updated_at: string;
|
||||||
|
created_at: string;
|
||||||
|
topic_id: number;
|
||||||
|
classification: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Point {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
source: string;
|
||||||
|
status: string;
|
||||||
|
analysis: string;
|
||||||
|
case: Case;
|
||||||
|
document_id: number | null;
|
||||||
|
updated_at: string;
|
||||||
|
created_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Params {
|
||||||
|
id: number;
|
||||||
|
is_comprehensively_reviewed: boolean;
|
||||||
|
name: string;
|
||||||
|
updated_at: string;
|
||||||
|
created_at: string;
|
||||||
|
slug: string;
|
||||||
|
rating: string;
|
||||||
|
urls: string[];
|
||||||
|
image: string;
|
||||||
|
documents: Document[];
|
||||||
|
points: Point[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface PrivacyPolicyResponse {
|
||||||
|
error: number;
|
||||||
|
message: string;
|
||||||
|
parameters: Params;
|
||||||
|
}
|
|
@ -0,0 +1,68 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export const fetchGitHubStats = async (github: string): Promise<GitHubStatsResponse | null> => {
|
||||||
|
const endpoint = `https://repo-info.as93.workers.dev/${github}`;
|
||||||
|
try {
|
||||||
|
return await fetch(endpoint).then((res) => res.json());
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching GitHub stats:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// fetch(`https://repo-info.as93.workers.dev/${github}`).then((res) => res.json());
|
||||||
|
|
||||||
|
export interface GitHubStatsResponse {
|
||||||
|
info: {
|
||||||
|
ownerUsername: string;
|
||||||
|
ownerAvatar: string;
|
||||||
|
description: string;
|
||||||
|
url: string;
|
||||||
|
homepage: string;
|
||||||
|
language: string;
|
||||||
|
topics: string[];
|
||||||
|
license: string;
|
||||||
|
isFork: boolean;
|
||||||
|
isArchived: boolean;
|
||||||
|
createdAt: string;
|
||||||
|
updatedAt: string;
|
||||||
|
size: number;
|
||||||
|
scarCount: number;
|
||||||
|
forksCount: number;
|
||||||
|
watchersCount: number;
|
||||||
|
};
|
||||||
|
languages: {
|
||||||
|
[key: string]: number;
|
||||||
|
};
|
||||||
|
updates: Array<{
|
||||||
|
type: string;
|
||||||
|
actor: {
|
||||||
|
username: string;
|
||||||
|
avatar: string;
|
||||||
|
};
|
||||||
|
repo: string;
|
||||||
|
action: string;
|
||||||
|
createdAt: string;
|
||||||
|
number?: number;
|
||||||
|
}>;
|
||||||
|
versions: Array<{
|
||||||
|
name: string;
|
||||||
|
commit: string;
|
||||||
|
zipball: string;
|
||||||
|
tarball: string;
|
||||||
|
}>;
|
||||||
|
contributors: Array<{
|
||||||
|
username: string;
|
||||||
|
avatar: string;
|
||||||
|
contributions: number;
|
||||||
|
}>;
|
||||||
|
commits: Array<{
|
||||||
|
sha: string;
|
||||||
|
authorName: string;
|
||||||
|
authorDate: string;
|
||||||
|
message: string;
|
||||||
|
authorUsername: string;
|
||||||
|
authorAvatar: string;
|
||||||
|
}>;
|
||||||
|
}
|
|
@ -0,0 +1,146 @@
|
||||||
|
|
||||||
|
export const fetchWebsiteInfo = async (url: string): Promise<WebsiteData | null> => {
|
||||||
|
const endpoint = `https://site-info-fetch.as93.workers.dev/?url=${url}`;
|
||||||
|
try {
|
||||||
|
return await fetch(endpoint).then((res) => res.json());
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error fetching website info:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
interface DNSRecord {
|
||||||
|
target: string;
|
||||||
|
ip: string;
|
||||||
|
country_code: string;
|
||||||
|
country_name: string;
|
||||||
|
isp: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DNSRecords {
|
||||||
|
ns: {
|
||||||
|
records: DNSRecord[];
|
||||||
|
};
|
||||||
|
mx: {
|
||||||
|
records: DNSRecord[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Engine {
|
||||||
|
name: string;
|
||||||
|
reference: string;
|
||||||
|
detected: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DomainBlacklist {
|
||||||
|
engines: Engine[];
|
||||||
|
detections: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FileType {
|
||||||
|
signature: string;
|
||||||
|
extension: string;
|
||||||
|
headers: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GeoLocation {
|
||||||
|
countries: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface HtmlForms {
|
||||||
|
number_of_total_forms: number;
|
||||||
|
number_of_total_input_fields: number;
|
||||||
|
two_text_inputs_in_a_form: boolean;
|
||||||
|
credit_card_field_present: boolean;
|
||||||
|
password_field_present: boolean;
|
||||||
|
email_field_present: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Redirection {
|
||||||
|
found: boolean;
|
||||||
|
external: boolean;
|
||||||
|
url: string;
|
||||||
|
redirects: any[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ResponseHeaders {
|
||||||
|
code: number;
|
||||||
|
status: string;
|
||||||
|
date: string;
|
||||||
|
last_modified: string;
|
||||||
|
etag: string;
|
||||||
|
accept_ranges: string;
|
||||||
|
vary: string;
|
||||||
|
content_encoding: string;
|
||||||
|
cache_control: string;
|
||||||
|
content_length: string;
|
||||||
|
content_type: string;
|
||||||
|
age: string;
|
||||||
|
content_security_policy_report_only: string;
|
||||||
|
strict_transport_security: string;
|
||||||
|
public_key_pins_report_only: string;
|
||||||
|
x_frame_options: string;
|
||||||
|
x_content_type_options: string;
|
||||||
|
x_xss_protection: string;
|
||||||
|
referrer_policy: string;
|
||||||
|
x_permitted_cross_domain_policies: string;
|
||||||
|
onion_location: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RiskScore {
|
||||||
|
result: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SecurityChecks {
|
||||||
|
[key: string]: boolean | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ServerDetails {
|
||||||
|
ip: string;
|
||||||
|
hostname: string;
|
||||||
|
continent_code: string;
|
||||||
|
continent_name: string;
|
||||||
|
country_code: string;
|
||||||
|
country_name: string;
|
||||||
|
region_name: string;
|
||||||
|
city_name: string;
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
|
isp: string;
|
||||||
|
asn: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SiteCategory {
|
||||||
|
[key: string]: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface UrlParts {
|
||||||
|
scheme: string;
|
||||||
|
host: string;
|
||||||
|
host_nowww: string;
|
||||||
|
port: null | number;
|
||||||
|
path: null | string;
|
||||||
|
query: null | string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface WebPage {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
keywords: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface WebsiteData {
|
||||||
|
dns_records: DNSRecords;
|
||||||
|
domain_blacklist: DomainBlacklist;
|
||||||
|
file_type: FileType;
|
||||||
|
geo_location: GeoLocation;
|
||||||
|
html_forms: HtmlForms;
|
||||||
|
redirection: Redirection;
|
||||||
|
response_headers: ResponseHeaders;
|
||||||
|
risk_score: RiskScore;
|
||||||
|
security_checks: SecurityChecks;
|
||||||
|
server_details: ServerDetails;
|
||||||
|
site_category: SiteCategory;
|
||||||
|
url_parts: UrlParts;
|
||||||
|
web_page: WebPage;
|
||||||
|
}
|
Loading…
Reference in New Issue