21 | LinkMagic Tools 22 |
23 |24 | Choose a tool below to get started. 25 |
26 | 27 |38 | Create short, memorable links and optionally generate a QR code for the shortened URL. 39 |
40 |44 | Generate a QR code for any URL. 45 |
46 |24 | Choose a tool below to get started. 25 |
26 | 27 |38 | Create short, memorable links and optionally generate a QR code for the shortened URL. 39 |
40 |44 | Generate a QR code for any URL. 45 |
46 |163 | {body} 164 |
165 | ) 166 | }) 167 | FormMessage.displayName = "FormMessage" 168 | 169 | export { 170 | useFormField, 171 | Form, 172 | FormItem, 173 | FormLabel, 174 | FormControl, 175 | FormDescription, 176 | FormMessage, 177 | FormField, 178 | } 179 | -------------------------------------------------------------------------------- /src/actions/shorten-url.ts: -------------------------------------------------------------------------------- 1 | "use server"; 2 | 3 | import { db } from '@/lib/firebase/admin'; // Import Firestore instance 4 | import { FieldValue } from 'firebase-admin/firestore'; // Import FieldValue for timestamp 5 | 6 | interface ShortenUrlInput { 7 | originalUrl: string; 8 | } 9 | 10 | interface ShortenUrlOutput { 11 | shortUrl: string; 12 | } 13 | 14 | const MAX_RETRIES = 5; // Maximum attempts to generate a unique short code 15 | const SHORT_CODE_LENGTH = 6; // Define length for the short code 16 | 17 | /** 18 | * Server action to shorten a URL and store the mapping in Firestore. 19 | * 20 | * @param input - The original URL. 21 | * @returns A promise resolving to the shortened URL information. 22 | * @throws {Error} If a unique short code cannot be generated or Firestore operation fails. 23 | */ 24 | export async function generateShortUrl(input: ShortenUrlInput): PromiseServer Configuration Error
33 |Could not connect to the link database. Please try again later or contact support.
34 |Code: {shortCode}
35 |Error Looking Up Link
68 |An error occurred while trying to retrieve the original URL. Please try again.
69 |Code: {shortCode}
70 |Processing Redirect...
102 | {shortCode && ( 103 |Code: {shortCode}
104 | )} 105 |153 | {result.data} 154 |
155 |