UNPKG

@chop-url/lib

Version:

A TypeScript library for URL shortening functionality with Cloudflare D1 database support

29 lines (28 loc) 929 B
import { ChopUrlConfig, UrlInfo } from './types'; /** * ChopUrl - A URL shortening library */ export declare class ChopUrl { private baseUrl; private db; constructor(config: ChopUrlConfig); /** * Creates a short URL for the given original URL * @throws {ChopUrlError} If the URL is invalid or database operation fails */ createShortUrl(url: string): Promise<UrlInfo>; /** * Retrieves the original URL for a given short ID * @throws {ChopUrlError} If the URL is not found or database operation fails */ getOriginalUrl(shortId: string): Promise<string>; /** * Gets detailed information about a shortened URL * @throws {ChopUrlError} If the URL is not found or database operation fails */ getUrlInfo(shortId: string): Promise<UrlInfo>; private validateConfig; private validateUrl; private validateShortId; private generateShortId; }