Skip to content

Function: initVurb()

ts
function initVurb<TContext>(): VurbInstance<TContext>;

Defined in: packages/core/src/core/initVurb.ts:346

Initialize a Vurb instance with a fixed context type.

Call once per project. All factory methods on the returned instance automatically inherit the context type — zero generic repetition.

Type Parameters

Type ParameterDefault typeDescription
TContextvoidThe application-level context type

Returns

VurbInstance<TContext>

A VurbInstance with context-typed factories

Example

typescript
// Single definition, typically in src/vurb.ts
export const f = initVurb<AppContext>();

// Build tools with the Fluent API
const listUsers = f.query('users.list')
    .describe('List all users')
    .withOptionalNumber('limit', 'Max results (default: 50)')
    .handle(async (input, ctx) => {
        return ctx.db.users.findMany({ take: input.limit ?? 50 });
    });