Write Mebel Darsono's API on real Hono and Postgres: pages, N+1, rate limits, webhooks, OpenAPI. 16 levels, played right in the browser with nothing to install.
An API is the door other programs use to ask for data. Here the door is an HTTP server: every request has a method and a path (GET /mebel), and the server answers with a status, headers and a body. In this game real Hono 4.13 and PostgreSQL 18 run in your browser. The chips you pick complete server.js, then the callers (the village app, Griya’s system in the city, a webhook sender) send real requests to app.fetch. What is graded is the server’s answers, the SQL Postgres logged, and what the database holds at the end of the day.
Pagination cuts a long list into pages, so one answer never carries the whole table. The server tells the caller how to ask for the next page, here with a next link. A well-behaved caller does not work addresses out itself: it follows next to the end.
N+1 happens when code fetches a list (1 query), then fetches related data for each row (N queries). With ten rows nobody notices; with a thousand the server waits for a thousand trips to the database. The fix: fetch the related data at once, with a JOIN or one WHERE id = ANY(...) query. In this game the number of queries is counted from Postgres’s own log.
Rate limiting caps how many requests one caller may send in a span of time, so one busy caller cannot use the server up for everyone else. A request over the limit is answered 429 Too Many Requests, usually with Retry-After (how many seconds to wait) and RateLimit-* headers.
API versions keep an old promise apart from a new one. Adding a field breaks nobody, but renaming or removing one breaks every caller that reads it. The most common way: the version in the address (/v1, /v2). Hono mounts a group of routes under one prefix with app.route().
A webhook turns the API around: another system calls your server when something happens. Since anyone can POST to that address, the sender signs each delivery with an HMAC and a shared secret, and the receiver works the signature out again. In this game the HMAC is worked out by the browser’s real WebCrypto, on both sides.