CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/hono-best-practices

Production Hono patterns — zValidator hooks, typed generics, error handling, middleware composition, testing, and multi-runtime deployment

87

2.57x
Quality

80%

Does it follow best practices?

Impact

98%

2.57x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-5/

Build a URL Shortener API

Problem/Feature Description

Build a URL shortener service using Hono and TypeScript, targeting Node.js. The service should allow users to create short URLs and track click analytics.

Endpoints:

  • POST /api/urls -- create a short URL (fields: originalUrl, customSlug optional)
  • GET /api/urls -- list all shortened URLs with click counts
  • GET /api/urls/:slug/stats -- get detailed stats for a URL (click count, last clicked)
  • GET /:slug -- redirect to the original URL (302 redirect, increment click count)
  • DELETE /api/urls/:slug -- delete a short URL

Business rules:

  • Original URL must be a valid URL
  • Custom slug must be alphanumeric, 3-20 characters
  • If no custom slug, generate a random 6-character slug
  • Slugs must be unique
  • Track click count and last clicked timestamp

Use in-memory storage.

Output Specification

Produce:

  • src/app.ts -- Hono application setup
  • src/server.ts -- Node.js entry point
  • src/routes/urls.ts -- URL management endpoints
  • src/routes/redirect.ts -- redirect handler
  • package.json -- with dependencies (no need to run npm install)
  • src/app.test.ts -- basic tests for the API

You may create additional files as needed.

evals

tile.json