alepha@docs:~/docs/packages/alepha/server$
cat core.md2 min read
Last commit:
#Alepha - Server
#Installation
Part of the alepha package. Import from alepha/server.
npm install alepha
#Overview
Convention-driven HTTP server with automatic validation and type inference.
Features:
- Type-safe API endpoints with schema validation
- Lower-level HTTP route definitions
- Automatic request/response validation via TypeBox
- Convention-based URL generation (
/api/{ActionName}) - Direct invocation (
run()) or HTTP (fetch()) - Built-in authentication integration
- Multipart file upload handling
- Response compression (gzip, brotli, zstd)
- Security headers (HSTS, CSP, X-Frame-Options, etc.)
- Content-type auto-negotiation (JSON, form-data, text)
- HTTP methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
- Error handling: BadRequestError, ValidationError, ForbiddenError, UnauthorizedError, ConflictError, NotFoundError
#API Reference
#Primitives
$action— Creates a server action primitive for defining type-safe HTTP endpoints.$circuit— * Consecutive failures before opening the circuit.$route— Create a basic endpoint.$sse— Schema configuration for an SSE endpoint.
#Providers
ServerHelmetProvider— Provides a configurable way to apply essential HTTP security headersServerNotReadyProvider— On every request, this provider checks if the server is ready.ServerProvider— Base server provider to handle incoming requests and route them.ServerRouterProvider— Main router for all routes server side.
#Environment Variables
Environment variables used to configure this module. These can be set in your .env file or through your deployment configuration.
| Variable | Type | Default | Description |
|---|---|---|---|
SERVER_HOST |
text | localhost | Set 0.0.0.0 to listen on all interfaces. |
SERVER_PORT |
integer | 3000 | Set 0 to listen on a random port. |
TRUST_PROXY |
boolean | true | Trust proxy headers for client IP |