import { Link, LinkQueryParams, PaginatedResponse } from '../types'; import { findLinkById, findLinkDetailsById, findLinks } from './repository'; /** * Get links with pagination information */ export async function getLinks(params: LinkQueryParams): Promise> { // Convert page number to offset const { page, limit = 10, ...otherParams } = params; const offset = page ? (page - 1) * limit : params.offset || 0; const result = await findLinks({ ...otherParams, limit, offset }); return { data: result.links, pagination: { total: result.total, limit: result.limit, offset: result.offset, page: result.page, totalPages: result.totalPages } }; } /** * Get a single link by ID with full details (including statistics) */ export async function getLinkById(linkId: string): Promise { return await findLinkById(linkId); } /** * Get a single link by ID - only basic info without statistics */ export async function getLinkDetailsById(linkId: string): Promise | null> { return await findLinkDetailsById(linkId); }