@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
51 lines • 1.91 kB
TypeScript
import { MastraBase } from '../base.js';
/**
* Base class for server adapters that provides app storage and retrieval.
*
* This class extends MastraBase to get logging capabilities and provides
* a framework-agnostic way to store and retrieve the server app instance
* (e.g., Hono, Express).
*
* Server adapters (like MastraServer from @mastra/hono or @mastra/express) extend this
* base class to inherit the app storage functionality while adding their
* framework-specific route registration and middleware handling.
*
* @template TApp - The type of the server app (e.g., Hono, Express Application)
*
* @example
* ```typescript
* // After server creation, the app is accessible via Mastra
* const app = mastra.getServerApp<Hono>();
* const response = await app.fetch(new Request('http://localhost/health'));
* ```
*/
export declare abstract class MastraServerBase<TApp = unknown> extends MastraBase {
#private;
constructor({ app, name }: {
app: TApp;
name?: string;
});
/**
* Get the app instance.
*
* Returns the server app that was passed to the constructor. This allows users
* to access the underlying server framework's app for direct operations
* like calling routes via app.fetch() (Hono) or using the app for testing.
*
* @template T - The expected type of the app (defaults to TApp)
* @returns The app instance cast to T. Callers are responsible for ensuring T matches the actual app type.
*
* @example
* ```typescript
* const app = adapter.getApp<Hono>();
* const response = await app.fetch(new Request('http://localhost/api/agents'));
* ```
*/
getApp<T = TApp>(): T;
/**
* Protected getter for subclasses to access the app.
* This allows subclasses to use `this.app` naturally.
*/
protected get app(): TApp;
}
//# sourceMappingURL=base.d.ts.map