Quick Setup
import { configureClient } from "@younndai/domains";
configureClient({
registryUrl: "https://domains.younndai.com",
timeout: 5000,
onWarn: (msg) => console.warn("[domains]", msg),
});
Options
| Option | Default | Description |
|---|
registryUrl | https://domains.younndai.com | Registry base URL |
timeout | 10000 | Request timeout (ms) |
onWarn | console.warn | Warning callback |
Shorthand Helpers
import {
setRegistryUrl,
setCacheAdapter,
clearDomainCache,
} from "@younndai/domains";
setRegistryUrl("https://domains-staging.younndai.com");
setCacheAdapter(myRedisAdapter);
clearDomainCache();
Custom Cache Adapter
import type { CacheAdapter, CacheEntry } from "@younndai/domains";
const redisCache: CacheAdapter = {
get<T>(key: string): CacheEntry<T> | null {
const raw = redisClient.getSync(`domains:${key}`);
return raw ? JSON.parse(raw) : null;
},
set<T>(key: string, entry: CacheEntry<T>): void {
redisClient.setSync(`domains:${key}`, JSON.stringify(entry));
},
delete(key: string): boolean {
return redisClient.delSync(`domains:${key}`) > 0;
},
clear(): void {
const keys = redisClient.keysSync("domains:*");
if (keys.length) redisClient.delSync(...keys);
},
size(): number {
return redisClient.keysSync("domains:*").length;
},
};
setCacheAdapter(redisCache);
Cache TTLs
| Content | TTL | Reason |
|---|
| Single domain (latest) | 24h | Domains change infrequently |
| Pinned version | ∞ | Immutable once published |
| Lists / search | 5 min | Updated more frequently |