@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
53 lines • 2.32 kB
TypeScript
import type { Context, Handler, MiddlewareHandler } from 'hono';
import type { DescribeRouteOptions } from 'hono-openapi';
import type { Mastra } from '../mastra/index.js';
import type { RequestContext } from '../request-context/index.js';
import type { ApiRoute, MastraAuthConfig, Methods } from './types.js';
export type { MastraAuthConfig, A2AAgentCardSigningConfig, A2AConfig, ContextWithMastra, CorsOptions, ApiRoute, HttpLoggingConfig, ValidationErrorContext, ValidationErrorResponse, ValidationErrorHook, } from './types.js';
export { MastraAuthProvider } from './auth.js';
export type { MastraAuthProviderOptions } from './auth.js';
export { CompositeAuth } from './composite-auth.js';
export { MastraServerBase } from './base.js';
export { SimpleAuth } from './simple-auth.js';
export type { SimpleAuthOptions } from './simple-auth.js';
type ParamsFromPath<P extends string> = {
[K in P extends `${string}:${infer Param}/${string}` | `${string}:${infer Param}` ? Param : never]: string;
};
/**
* Variables available in the Hono context for custom API route handlers.
* These are set by the server middleware and available via c.get().
*/
type CustomRouteVariables = {
mastra: Mastra;
requestContext: RequestContext;
};
type RegisterApiRouteOptions<P extends string> = {
method: Methods;
openapi?: DescribeRouteOptions;
handler?: Handler<{
Variables: CustomRouteVariables;
}, P, ParamsFromPath<P>>;
createHandler?: (c: Context) => Promise<Handler<{
Variables: CustomRouteVariables;
}, P, ParamsFromPath<P>>>;
middleware?: MiddlewareHandler | MiddlewareHandler[];
/**
* Route-specific CORS configuration.
*/
cors?: ApiRoute['cors'];
/**
* When false, skips Mastra auth for this route (defaults to true)
*/
requiresAuth?: boolean;
/**
* Explicit RBAC permission for the route.
*/
requiresPermission?: ApiRoute['requiresPermission'];
/**
* Optional FGA configuration for resource-level authorization.
*/
fga?: ApiRoute['fga'];
};
export declare function registerApiRoute<P extends string>(path: P, options: RegisterApiRouteOptions<P>): ApiRoute;
export declare function defineAuth<TUser>(config: MastraAuthConfig<TUser>): MastraAuthConfig<TUser>;
//# sourceMappingURL=index.d.ts.map