Production Hono patterns — zValidator hooks, typed generics, error handling, middleware composition, testing, and multi-runtime deployment
87
80%
Does it follow best practices?
Impact
98%
2.57xAverage score across 5 eval scenarios
Passed
No known issues
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 countsGET /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 URLBusiness rules:
Use in-memory storage.
Produce:
src/app.ts -- Hono application setupsrc/server.ts -- Node.js entry pointsrc/routes/urls.ts -- URL management endpointssrc/routes/redirect.ts -- redirect handlerpackage.json -- with dependencies (no need to run npm install)src/app.test.ts -- basic tests for the APIYou may create additional files as needed.