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

54 lines (53 loc) • 2.09 kB
import http from 'http'; import express from 'express'; import { ILogger } from '@microsoft/teams.common'; import { HttpMethod, IHttpServerAdapter, HttpRouteHandler } from './adapter'; /** * Express adapter for HttpServer * * Handles Express-specific HTTP framework concerns: * - Express app creation and middleware setup * - Route registration via Express routing * - Request/response data extraction and sending * - Server lifecycle management */ export declare class ExpressAdapter implements IHttpServerAdapter { readonly get: express.Application['get']; readonly post: express.Application['post']; readonly patch: express.Application['patch']; readonly put: express.Application['put']; readonly delete: express.Application['delete']; readonly route: express.Application['route']; readonly use: express.Application['use']; protected express: express.Application; protected server?: http.Server; protected logger: ILogger; protected onError?: (err: Error) => void; constructor(serverOrApp?: http.Server | express.Application, options?: { logger?: ILogger; onError?: (err: Error) => void; }); /** * Register a route handler for a given HTTP method and path */ registerRoute(method: HttpMethod, path: string, handler: HttpRouteHandler): void; /** * Start the server listening on the specified port */ start(port: number | string): Promise<void>; /** * Serve static files from a directory. * * No CORS headers are set: Teams loads tab content inside an iframe (subject * to the page's CSP `frame-ancestors` directive), not via cross-origin * `fetch`/XHR, so a wildcard `Access-Control-Allow-Origin` was permissive * without a corresponding use case. Callers that need cross-origin reads of * the served assets should layer their own CORS middleware at the consuming * route. */ serveStatic(path: string, directory: string): void; /** * Stop the server and close all connections */ stop(): Promise<void>; }