docs
evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a simple URL shortener API using Koa that manages short links and redirects users to the original URLs.
Your API should support the following endpoints:
POST /shorten - Creates a new short link
url (the original URL to shorten) and optional customSlug (custom short code)customSlug is provided and available, use it as the short codecustomSlug is not provided, generate a random 6-character alphanumeric code{ "shortCode": "abc123" }customSlug is already takenGET /:shortCode - Redirects to the original URL
GET /stats/:shortCode - Returns statistics for a short link
shortCode, originalUrl, and clicks (number of times redirected)DELETE /links/:shortCode - Deletes a short link
// Koa application with routes that handle:
// POST /shorten - create short link
// GET /:shortCode - redirect to original URL
// GET /stats/:shortCode - get link statistics
// DELETE /links/:shortCode - delete short linkProvides the web framework.
Provides routing with parameter extraction from URL paths.
Parses JSON request bodies.