Share
Rate limit a route handler with Postgres and no extra service
A fixed one-minute window, counted in the database you already pay for. Good enough to stop someone looping your AI endpoint. Delete old rows with a daily cron. For serious abuse you want something in front of the app, not in it.
For a single-instance app this is plenty. Make sure the upsert returns the new count so it's one round trip.
chidi_eze
It does, inside the function. Good to spell out though.
lena_ops