• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
stevekrouse

stevekrouse

usageAlert

Public
Like
usageAlert
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
Code
/
Search
README.md

HTTP Val Usage Alert

As of Oct 29, 2024, HTTP vals can comfortably run 2k times per minute.

If you want to get alerted if you val is getting close to those limits, you can wrap your HTTP handler in this middleware:

Create val
import { usageAlert } from "https://esm.town/v/stevekrouse/usageAlert" async function sampleHandler(req: Request): Promise<Response> { return new Response("Hello, World!"); } export default usageAlert(sampleHandler);

It keeps a sliding window count of requests in memory (which is perfect for this sittuation) and will send you an email using @std/email if you go over 1k req / min.

Migrated from folder: Archive/usageAlert

Code
README.mdmain.tsx
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.