Function: createGroup()
ts
function createGroup<TContext>(config): CompiledGroup<TContext>;Defined in: packages/core/src/core/createGroup.ts:174
Create a compiled, frozen tool group from a declarative config.
The returned object has O(1) action dispatch via a pre-built Map. All middleware chains are pre-composed at creation time — zero runtime overhead on each call.
Type Parameters
| Type Parameter | Default type | Description |
|---|---|---|
TContext | void | Application context type |
Parameters
| Parameter | Type | Description |
|---|---|---|
config | GroupConfig<TContext> | Group configuration with actions |
Returns
CompiledGroup<TContext>
A frozen CompiledGroup ready for execution
Example
typescript
const tasks = createGroup({
name: 'tasks',
middleware: [logMiddleware],
actions: {
list: {
readOnly: true,
handler: async (ctx) => success(await ctx.db.tasks.findMany()),
},
create: {
schema: z.object({ title: z.string() }),
handler: async (ctx, args) => success(await ctx.db.tasks.create(args)),
},
},
});
const result = await tasks.execute(ctx, 'create', { title: 'Buy milk' });