StartServerOptions interface
Options for configuring the Express server started by startServer.
- Extends
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 |
Inherited Properties
| configuration |
Optional host-scoped external configuration used to resolve the authentication
configuration and runtime options of a newly created For an |
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
Inherited Property Details
configurationContext
Optional host-scoped external configuration used to resolve the authentication
configuration and runtime options of a newly created CloudAdapter (e.g. emitStackTrace,
validateServiceUrl, outbound host validation).
For an AgentApplication, this defaults to agent.options.configurationContext when
omitted. A plain ActivityHandler has no built-in context, so it must be supplied here to
participate in host-scoped configuration.
configurationContext?: ConfigurationContext
Property Value
Inherited From CreateCloudAdapterOptions.configurationContext