Problem
stx supports manual apiRoutes and an external apiRouter, but does not offer a unified file-based endpoint convention with response-type inference for client fetching.
For standalone apps, a handler file such as server/api/users.get.ts should be routable without a second manual route declaration, and clients should be able to infer its response shape.
Existing foundation
Reviewed at 7d93c4c: config types and production-server.ts.
Scope and acceptance criteria
- Define an endpoint directory convention with HTTP-method suffixes and dynamic parameters.
- Discover handlers during development and package them for production.
- Generate a route/response type map for a typed client-fetch API.
- Preserve manual apiRoutes and apiRouter integrations with documented precedence.
- Diagnose ambiguous routes and unsupported methods.
- Keep server-only implementation code out of browser bundles.
- Test the same endpoint contract through development and production serving.
- Document how standalone stx and Stacks-hosted applications opt in.
Use existing Stacks/Bun router facilities where appropriate; this should not introduce a second backend framework.
Prior art: Nuxt server directory and typed data fetching.