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

karfau

isRequest

Public
Like
2
isRequest
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

A type guard for vals that expect a WebApi Request as the first parameter.

Since a val can be invoked by run, web, express or even email, the correct type for a web endpoint should be req?: Request | unknown.

By using this type guard and handling the false case, all later code can safely access the request:

export const myVal = (req?: Request | unknown) => { if (!@karfau.isRequest(req)) { return `This val has to be used with the web endpoint, see ${@neverstew.thisValUrl()}`; } if (req.method === 'GET') { // ... } }

Migrated from folder: web/isRequest

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
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.