Examples

Explore example Vercube applications to learn common patterns and best practices.

Below you'll find a collection of example applications that demonstrate various features and use cases of Vercube. These examples showcase common patterns, best practices, and different ways to structure your applications. Each example comes with detailed explanations and source code that you can use as a reference for your own projects.

ExampleSourceTry
hello-worldexamples/basenpx giget gh:vercube/vercube/examples/base vercube-base
aws-lambdaexamples/aws-lambdanpx giget gh:vercube/vercube/examples/aws-lambda vercube-aws
azure-functionsexamples/azure-functionsnpx giget gh:vercube/vercube/examples/azure-functions vercube-azure
websocketsexamples/websocketsnpx giget gh:vercube/vercube/examples/websockets vercube-wss

Playground patterns

The playground/ app includes reference implementations for common patterns. One example is a typed request-context wrapper that provides compile-time safety for RequestContext keys and values. See:

  • playground/src/Services/TypedRequestContext.ts
  • playground/src/Services/RequestContextKeys.ts

Usage looks like this:

import { Container, Inject } from '@vercube/di';
import { TypedRequestContext } from '../Services/TypedRequestContext';
import { RequestIdKey } from '../Services/RequestContextKeys';

@Inject(Container)
private gContainer!: Container;

const ctx = this.gContainer.resolve(TypedRequestContext);
ctx.set(RequestIdKey, crypto.randomUUID());

const requestId = ctx.get(RequestIdKey);

Rationale

  • Avoids string-typo bugs by centralizing keys.
  • Enforces value types at compile time (e.g., requestStartTime is always a number).
  • Enables incremental adoption: typed access can live alongside existing string-based calls.
Previous

Configuration

Configure your Vercube application

Next