This API provides short link generation and tracking functionality. It uses Fastify as the web framework, Zod for data validation, Postgres for database operations, and Redis for caching.
- Install dependencies:
pnpm install
- Setup Database:
pnpm run setup-database
- Start the server:
pnpm run dev
- Description: Retrieve the original URL corresponding to a short link code.
- Request Parameters:
code
(string) - Response: Redirects to the original URL or returns an error message.
- Description: Retrieve all short links ordered by creation date.
- Response: Array of short link objects.
- Description: Create a new short link.
- Request Body:
{ code: string, url: string }
- Response:
{ shortLinkId: number }
or error message for duplicates.
- Description: Retrieve top 50 ranked short links based on clicks.
- Response: Array of short link metrics.
- Zod schemas are used for validating request data.
- Proper error handling for database and server errors.
- Use built in http client to test routes