@venturekit/runtime
Installation
Section titled “Installation”npm install @venturekit/runtime@devWhat It Provides
Section titled “What It Provides”Handler
Section titled “Handler”The unified handler() function wraps your Lambda business logic:
import { handler } from '@venturekit/runtime';
// Publicexport const main = handler(async (_body, ctx, logger) => { return { status: 'ok' };});
// Authenticatedexport const main = handler(async (body, ctx, logger) => { return { id: '123', name: body.name };}, { scopes: ['api.write'] });Context
Section titled “Context”Typed request context with user info, tenant context, and metadata:
import { buildContext, extractUserContext, extractLocale } from '@venturekit/runtime';Key fields: requestId, timestamp, method, path, user, tenant, locale, queryParams, tx, intentOutputs.
Response Helpers
Section titled “Response Helpers”import { success, created, noContent, error, errorResponse, redirect } from '@venturekit/runtime';Errors
Section titled “Errors”Structured error classes that map to HTTP status codes:
import { VentureError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, ValidationError, RateLimitError, InternalError, ServiceUnavailableError, isVentureError,} from '@venturekit/runtime';Logger
Section titled “Logger”Structured logging via Pino:
import { Logger, createLogger, logger } from '@venturekit/runtime';Middleware
Section titled “Middleware”Composable middleware system:
import { compose, loggingMiddleware, corsMiddleware, timeoutMiddleware, errorBoundaryMiddleware } from '@venturekit/runtime';WebSocket Connection Store
Section titled “WebSocket Connection Store”For real-time applications:
import { connectionStore } from '@venturekit/runtime';
await connectionStore.save(connectionId);await connectionStore.authenticate(connectionId, { userId, email });await connectionStore.sendToUser(domain, stage, userId, data);await connectionStore.broadcast(domain, stage, data);Dependencies
Section titled “Dependencies”@venturekit/core— requiredpino— structured logging@venturekit/data— optional peer (for transactional handlers)- AWS SDK — optional peers (for WebSocket connection store)
Related
Section titled “Related”- Handlers — deep dive into the handler API
- Middleware — writing and composing middleware
- Error Handling — structured error classes
- WebSockets — real-time applications
- API Reference — full type documentation