Skip to content

@venturekit/runtime

Terminal window
npm install @venturekit/runtime@dev

The unified handler() function wraps your Lambda business logic:

import { handler } from '@venturekit/runtime';
// Public
export const main = handler(async (_body, ctx, logger) => {
return { status: 'ok' };
});
// Authenticated
export const main = handler(async (body, ctx, logger) => {
return { id: '123', name: body.name };
}, { scopes: ['api.write'] });

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.

import { success, created, noContent, error, errorResponse, redirect } from '@venturekit/runtime';

Structured error classes that map to HTTP status codes:

import {
VentureError, BadRequestError, UnauthorizedError, ForbiddenError,
NotFoundError, ConflictError, ValidationError, RateLimitError,
InternalError, ServiceUnavailableError, isVentureError,
} from '@venturekit/runtime';

Structured logging via Pino:

import { Logger, createLogger, logger } from '@venturekit/runtime';

Composable middleware system:

import { compose, loggingMiddleware, corsMiddleware, timeoutMiddleware, errorBoundaryMiddleware } from '@venturekit/runtime';

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);
  • @venturekit/core — required
  • pino — structured logging
  • @venturekit/data — optional peer (for transactional handlers)
  • AWS SDK — optional peers (for WebSocket connection store)