PSPublicAPI.psm1

$baseUri = 'https://api.publicapis.org/'

Add-Type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
    ServicePoint srvPoint, X509Certificate certificate,
    WebRequest request, int certificateProblem) {
        return true;
    }
}
"@


[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

$allProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $allProtocols

#Get public and private function definition files.
$public = @( Get-ChildItem -Path $PSScriptRoot\Public\ -Filter *.ps1 -Exclude *.Tests.ps1 -Recurse -ErrorAction SilentlyContinue )
$private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -Exclude *.Tests.ps1 -ErrorAction SilentlyContinue )

#Dot source the files
foreach ($import in @($public + $private)) {
    try {
        . $import.fullname
    }
    catch {
        Write-Error -Message "Failed to import function $($import.fullname): $_"
    }
}

#Export only the functions in public scripts
Export-ModuleMember -Function $Public.Basename -Variable baseUri