| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import {ServerResponse} from 'node:http';
- import {IncomingMessage} from 'node:http';
- import {DebuggableService, ServiceContainer} from '@e22m4u/js-service';
- /**
- * Static file route.
- */
- export type HttpStaticRoute = {
- remotePath: string;
- resourcePath: string;
- regexp: RegExp;
- isFile: boolean;
- };
- /**
- * Http static router.
- */
- export class HttpStaticRouter extends DebuggableService {
- /**
- * Constructor.
- *
- * @param container
- */
- constructor(container?: ServiceContainer);
- /**
- * Add route.
- *
- * @param remotePath
- * @param resourcePath
- */
- addRoute(remotePath: string, resourcePath: string): this;
- /**
- * Match route.
- *
- * @param req
- */
- matchRoute(req: IncomingMessage): HttpStaticRoute | undefined;
- /**
- * Send file by route.
- *
- * @param route
- * @param req
- * @param res
- */
- sendFileByRoute(
- route: HttpStaticRoute,
- req: IncomingMessage,
- res: ServerResponse,
- ): void;
- }
|