Examples
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.
- Source
hello-world
The smallest Vercube app, a good place to start.
npx giget gh:vercube/vercube/examples/base vercube-base - Source
custom-plugin
A plugin in vercube.config.ts with configure, setup and setupCLI.
npx giget gh:vercube/vercube/examples/custom-plugin vercube-custom-plugin - Source
aws-lambda
A Vercube app deployed as an AWS Lambda function.
npx giget gh:vercube/vercube/examples/aws-lambda vercube-aws - Source
azure-functions
A Vercube app deployed as Azure Functions.
npx giget gh:vercube/vercube/examples/azure-functions vercube-azure - Source
websockets
A Vercube app with WebSocket handlers.
npx giget gh:vercube/vercube/examples/ws vercube-ws
Playground patterns
The playground/ app includes reference implementations for common patterns.
API documentation (Schema + Scalar)
playground/ registers @vercube/schema via SchemaPlugin. After pnpm dev, open:
/_schema/- OpenAPI JSON/_schema/docs- Scalar API Reference
See playground/src/Controllers/PlaygroundController.ts for @Schema with Zod response models. Full guide: Schema module.
Typed request context
One example is a typed request-context wrapper that provides compile-time safety for RequestContext keys and values. See:
playground/src/Services/TypedRequestContext.tsplayground/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.,
requestStartTimeis always anumber). - Enables incremental adoption: typed access can live alongside existing string-based calls.