StartServerOptions interface
Options for configuring the Express server started by startServer.
Properties
| auth |
Optional custom authentication configuration. If not provided, configuration will be loaded from environment variables using loadAuthConfigFromEnv(). |
| before |
A callback invoked with the Express app before Note: The agent messages route is registered after this callback.
Avoid adding catch-all routes (e.g., Example
|
| port | The port to listen on. Defaults to |
| rate |
Optional rate limiting configuration for the messages endpoint. If not provided, no rate limiting is applied. Specify windowMs (in milliseconds) and max (number of requests) to enable rate limiting. Example
|
| route |
The route path for the agent messages endpoint. Defaults to |
Property Details
authConfig
Optional custom authentication configuration. If not provided, configuration will be loaded from environment variables using loadAuthConfigFromEnv().
authConfig?: AuthConfiguration
Property Value
beforeListen
A callback invoked with the Express app before listen() is called.
Use this to add custom routes, middleware, or static file serving.
Note: The agent messages route is registered after this callback.
Avoid adding catch-all routes (e.g., app.all('*', ...) or app.use('*', ...))
here, as they will shadow the messages endpoint.
Example
startServer(agent, {
beforeListen: (app) => {
app.get('/health', (req, res) => res.json({ status: 'ok' }));
}
});
beforeListen?: (app: Express) => void
Property Value
(app: Express) => void
port
The port to listen on. Defaults to process.env.PORT or 3978.
port?: string | number
Property Value
string | number
rateLimitOptions
Optional rate limiting configuration for the messages endpoint. If not provided, no rate limiting is applied. Specify windowMs (in milliseconds) and max (number of requests) to enable rate limiting.
Example
startServer(agent, {
rateLimitOptions: {
windowMs: 15 * 60 * 1000, // 15 minutes
max: 1000 // limit each IP to 1000 requests per windowMs
}
});
rateLimitOptions?: { max: number, windowMs: number }
Property Value
{ max: number, windowMs: number }
routePath
The route path for the agent messages endpoint. Defaults to '/api/messages'.
routePath?: string
Property Value
string