Spaces:
Running
Running
Download api/v2/_services/proofSystem.ts from Sarvesh213/getcert-backend: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/spaces/Sarvesh213/getcert-backend/resolve/main/api/v2/_services/proofSystem.ts
- Command line
-
hf download hf://spaces/Sarvesh213/getcert-backend/api/v2/_services/proofSystem.ts
-
curl -L -o proofSystem.ts https://huggingface.co/spaces/Sarvesh213/getcert-backend/resolve/main/api/v2/_services/proofSystem.ts
1.82 kB
| import type { ProofInput, ProofValidation } from '../_types.js'; | |
| const WEB_HOSTS = ['vercel.app', 'onrender.com', 'netlify.app']; | |
| const NOTEBOOK_HOSTS = ['colab.research.google.com', 'kaggle.com']; | |
| const DESIGN_HOSTS = ['behance.net', 'dribbble.com', 'adobe.com']; | |
| function hasKnownHost(url: string, hosts: string[]): boolean { | |
| try { | |
| const host = new URL(url).hostname.toLowerCase(); | |
| return hosts.some((candidate) => host.endsWith(candidate)); | |
| } catch { | |
| return false; | |
| } | |
| } | |
| export function validateProof(input: ProofInput): ProofValidation { | |
| const provided: string[] = []; | |
| const missing: string[] = []; | |
| if (input.liveDemoUrl) { | |
| provided.push('liveDemoUrl'); | |
| } | |
| if (input.notebookUrl) { | |
| provided.push('notebookUrl'); | |
| } | |
| if (input.portfolioUrl) { | |
| provided.push('portfolioUrl'); | |
| } | |
| if (input.projectType === 'design') { | |
| const ok = !!input.portfolioUrl && hasKnownHost(input.portfolioUrl, DESIGN_HOSTS); | |
| if (!ok) { | |
| missing.push('Valid design portfolio URL (Behance/Dribbble)'); | |
| } | |
| return { | |
| passed: ok, | |
| requiredProof: 'Design portfolio link', | |
| providedProof: provided, | |
| missing, | |
| }; | |
| } | |
| if (input.projectType === 'web') { | |
| const ok = !!input.liveDemoUrl && hasKnownHost(input.liveDemoUrl, WEB_HOSTS); | |
| if (!ok) { | |
| missing.push('Valid web deployment URL (Vercel/Render/Netlify)'); | |
| } | |
| return { | |
| passed: ok, | |
| requiredProof: 'Web deployment link', | |
| providedProof: provided, | |
| missing, | |
| }; | |
| } | |
| const notebookOk = !!input.notebookUrl && hasKnownHost(input.notebookUrl, NOTEBOOK_HOSTS); | |
| if (!notebookOk) { | |
| missing.push('Valid Colab/Kaggle demo link'); | |
| } | |
| return { | |
| passed: notebookOk, | |
| requiredProof: 'Notebook/demo proof link', | |
| providedProof: provided, | |
| missing, | |
| }; | |
| } | |