nostr-deploy-server
Version:
Node.js server for hosting static websites under npub subdomains using Nostr protocol and Blossom servers
105 lines • 2.97 kB
TypeScript
export interface CacheWarmerOptions {
/** Time period to warm cache for (e.g., '1d', '1w', '1m', '7d', '30d') */
timePeriod: string;
/** List of pubkeys to warm cache for. If empty, discovers from recent events */
pubkeys?: string[];
/** Maximum number of events to process per pubkey */
maxEventsPerPubkey?: number;
/** Maximum number of concurrent operations */
concurrency?: number;
/** Whether to warm file content cache (slower but more complete) */
warmFileContent?: boolean;
/** Custom relays to use for warming (defaults to config relays) */
customRelays?: string[];
/** Custom blossom servers to use (defaults to config servers) */
customBlossomServers?: string[];
/** Dry run mode - don't actually cache, just log what would be cached */
dryRun?: boolean;
}
export interface CacheWarmerStats {
startTime: Date;
endTime: Date;
duration: number;
timePeriod: string;
pubkeysProcessed: number;
eventsProcessed: number;
filesWarmed: number;
relayListsWarmed: number;
blossomServersWarmed: number;
domainsWarmed: number;
blobUrlsWarmed: number;
fileContentWarmed: number;
errors: number;
cacheHits: number;
cacheMisses: number;
totalOperations: number;
averageOperationTime: number;
operationDetails: {
pubkeyDiscovery: number;
relayQueries: number;
blossomQueries: number;
cacheOperations: number;
};
}
export declare class CacheWarmer {
private nostrHelper;
private blossomHelper;
private config;
private stats;
constructor();
private initializeStats;
/**
* Parse time period string to Unix timestamp
* Supports formats like: '1d', '7d', '1w', '2w', '1m', '3m', '1y'
*/
private parseTimePeriod;
/**
* Discover pubkeys from recent events if not provided
*/
private discoverPubkeys;
/**
* Warm cache for a single pubkey
*/
private warmPubkeyCache;
/**
* Warm relay list cache for a pubkey
*/
private warmRelayList;
/**
* Warm blossom servers cache for a pubkey
*/
private warmBlossomServers;
/**
* Warm static file mappings for a pubkey
*/
private warmStaticFiles;
/**
* Warm file content cache
*/
private warmFileContent;
/**
* Run cache warming with specified options
*/
run(options: CacheWarmerOptions): Promise<CacheWarmerStats>;
/**
* Split array into chunks for controlled concurrency
*/
private chunkArray;
/**
* Finalize stats and return results
*/
private finalizeStats;
/**
* Print formatted statistics
*/
printStats(stats: CacheWarmerStats): void;
/**
* Clean up resources
*/
cleanup(): void;
}
/**
* CLI interface for cache warming
*/
export declare function runCacheWarmerCLI(): Promise<void>;
//# sourceMappingURL=cache-warmer.d.ts.map