UNPKG

@microsoft/teams.apps

Version:

<p> <a href="https://www.npmjs.com/package/@microsoft/teams.apps" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.apps/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.apps?activeTab=code

30 lines (29 loc) 1.28 kB
import { Activity, InvokeResponse } from '@microsoft/teams.api'; import { IActivityContext } from '../contexts'; import { IRoutes } from '../routes'; import { RouteHandler } from '../types'; import { Route, RouteType } from './route'; export declare class Router<TExtraCtx extends Record<string, any> = Record<string, any>> { protected readonly routes: Route<keyof IRoutes, TExtraCtx>[]; /** * select routes that match the inbound activity * @param activity the inbound activity */ select(activity: Activity): RouteHandler<import("../contexts").IBaseActivityContext<Activity, Record<string, any>>, any>[]; /** * register a new route * @param route the route to register */ register<Name extends keyof IRoutes>(route: Route<Name, TExtraCtx>): this; /** * register a middleware * @param callback the callback to invoke */ use(callback: RouteHandler<IActivityContext<Activity, TExtraCtx>, void | InvokeResponse>, type?: RouteType): this; /** * register an activity route * @param event event to subscribe to * @param callback the callback to invoke */ on<Name extends keyof IRoutes>(event: Name, callback: Exclude<IRoutes<TExtraCtx>[Name], undefined>, type?: RouteType): this; }